Java-like Collections in PHP -


I'm learning PHP5 (PHP4 days when I checked PHP) and I was happy to see that Java is more than PHP5 OO PHP4, but there is a problem that I have due to my Java background I feel quite nervous: ARRAYS

I am reading "Professional PHP6" (WOX) and it shows my collection implementation. I have found a variety of other things based on SPL I have also found that A There is some kind of collection in PL (ArrayAbject)

However, I'm surprised because I do not really see people using the collection in PHP, they like arrays.

So, is it not a good idea to use archives in PHP like people are using ArrayLists instead of the original ARMs in Java? After all, PHP arrays are not really like Java arrays. Collections in Java make lots of emotions because it is a strongly typed language, it is a "car" There is a collection to say and the second part of "Motorbikes" is.

However, due to the dynamically typed nature, in PHP, it is quite common to sacrifice the formalities of collections. Arrays are enough to be used as normal containers of various object types (cars, motorbikes, etc). Also, additional benefits come from the fact that arrays can be changed very easily (which can sometimes lead to a major disadvantage if incorrect error testing is absent).

I am coming from Java background and I found that using the collection design pattern in PHP does not buy much in the way of advantages (no multi-threading, no optimization of memory allocation, no iterators etc) is.

If you are looking for any of these benefits, it would be better to create a wrapper class around the array, apply the La carte to each feature (iterators, etc.).


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -