As i am reading manual of php for array functions, i see that some functions of arrays uses call by reference whereas some use call by value. Eg. array_slice uses call by value, array_splice uses call by reference. How do i remember these things without refering to the manual and thereby increase my productivity? What exact thought did the developer of php have in mind, on what basis has he made some functions made us pass values pass by value and some pass by reference? Is it done haphazardly?
Thanks in advanece 🙂
I find the easiest thing is to have an IDE that can give you information about the expected parameters as you type.
Probably, or through lack of foresight. Sadly, PHP’s array functions (and much of the overall standard library) lack consistency in naming and parameters. This point is raised often by people criticizing PHP.
Help is on the way in the PHP 5 world, though. Check out the Array object for example, for example. It doesn’t seem to cover all array functions, but as pointed out by Gordon in this comment, it’s a good start.