Java-like Collections in PHP

后端 未结 7 1340
情话喂你
情话喂你 2021-01-04 01:48

I\'m learning PHP5 (last time I checked PHP was in PHP4 days) and I\'m glad to see that PHP5 OO is more Java-alike than the PHP4 one but there\'s still an issue that makes m

7条回答
  •  有刺的猬
    2021-01-04 02:34

    I am very pro collection objects in PHP, they can be used to add type safety, impliment easy to use search, sort and manipulation functionality, and represent the correct OO approach rather then using arrays and the multitude of useful but procedual functions that operate on them in differing patterns all over the source.

    We have various collections that we use for various purposes all neatly inherited promoting type safety, consistent coding standards and a high level of code reuse.

    But ultimatley, they are all array's internally!

    I suppose really it comes down to choice, but in my object oriented world I like to keep easily repeatable segments of code such as sort and search algorithms in base classes, and I find the object notation more self documenting.

提交回复
热议问题