Functions vs. Static Methods

前端 未结 4 1874
心在旅途
心在旅途 2020-12-16 15:01

I\'ve got a few functions that deal with cookies. Would it be a horrible idea to group them by moving them to a class of their own and use them as static methods?

F

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-16 15:43

    That would be a great way of organising your code, but why use static functions, just make a class for the required functionality.

    Or as said above use namespaces, but I'm not particularly familiar with the pros/cons of them.

    $cookie->get() is nicer to work with than cookie_get() in my opinion

提交回复
热议问题