As PHP borrows most of its object oriented features from java. I would like to know whether PHP and java both uses the same concept of pass by value?
I know Java is not pass by reference.Its just that object references are passed by value. How about PHP? Does PHP support pass by reference?
In PHP, you only pass stuff by reference if you declare a function and litter it with ampersands:
There is call-time pass-by-reference as well (i.e. passing variables by reference when you call functions), but I shan’t go on about it because it presents a risk for unexpected behavior. It’s better practice to declare parameters to be passed by reference in your function signatures instead.
As for objects: in PHP 4, objects are all passed by value. In PHP 5, references to objects are passed by value, just like in Java.