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 referring 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?
How do i remember these things without refering to the manual and thereby increase my productivity?
I find the easiest thing is to have an IDE that can give you information about the expected parameters as you type.
Is it done haphazardly?
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.