difference between libraries and helpers in php frameworks

前端 未结 5 699
孤街浪徒
孤街浪徒 2020-12-16 02:48

if i\'ve got string functions i use a lot, should i put them in a helper class or a library class?

functions like: truncate string if longer than 30 characters, retu

5条回答
  •  难免孤独
    2020-12-16 03:30

    Helpers are the classes that help something already there for example there can be a helper for:

    array
    string
    url
    etc

    A library is something that can be any solution; it could be created for the first time by you and no one else has created.

    Because you are dealing with a string (something already there), you should put it in a helper class, or modify the string helper class of the framework (if there is one). However, this is a convention or standard but you can create a library for it too if you are creating something really cool for string handling with quite some functions.

提交回复
热议问题