Essentially there are not pointers in PHP. In my opinion the only time you will want to pass an array by reference to a function is when you want the function to modify the value of the array.
When considering the speed efficiency, you should first think about where the bottleneck in the operations are going to be. Most likely, under a scrutinizing eye, the bottleneck for any PHP application will be in the actual interpretation of the script, not the memory access and allocation (which happens in RAM, and is usually done in the MMU)
Additionally, you will not need to worry about memory management issues, as PHP is a dynamic-typed language, and will not perform any 'dangerous' operations. In fact, unless you specifically unset() a variable, it remains in memory until the end of the scripts lifetime, even if you leave the scope in which the variable was declared in.
PHP.net is the best reference by far for the inner workings of the language. I would strongly suggest you take the time to do a little reading.
Hi all,
Could anyone help me about returning the array from a function in PHP? What is the right way to do it in PHP?
I've tried by reference and also returned as a local variable. Both works but is they good for big arrays??? Is they safe??
However, my current knowledge prompts me (from C++) that returning a pointer or a reference might be dangerous (this variable can go out of scope).
I appreciate for your information.
P.S. Can you also suggest any documentation about the good style of programming in PHP. I often have such questions:(.