difference between libraries and helpers in php frameworks

前端 未结 5 695
孤街浪徒
孤街浪徒 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:40

    I assume you are using CodeIgniter.

    Since you already write that you don't need to instantiate an object and will use it in it's static methods, then making it into helper will be make sense than making it into library.

    In CI, helpers is also managed, once loaded, second attempt to load it will be omitted. You can open the CI's build in helper to learn what it does, then compare it with libraries. By knowing the purpose, you can then decide yourself, helpers or libraries.

提交回复
热议问题