I know there's the option to pass开发者_开发问答 a value by reference, simply by writing something like
function foo(&$bar) {...}
But from Objective-C I'm used to believe that objects are always passed by reference (since the variables referencing them are just pointers whose values are just a memory address). Only sctructures and primitives would have to explicitely be passed by reference.
How's that going on in PHP? Must I be sure to put that address operator & into every parameter to enhance performance when passing objects?
Only in versions prior to PHP5. In PHP5 objects are always passed by reference.
PHP5 passes object by reference. To pass them by value you can use the keyword clone.
精彩评论