Are Php function parameters passed as references to object or as copy of object?
It’s very clear in C++ but in Php5 I don’t know.
Example:
<?php
$dom = new MyDocumentHTMLDom();
myFun($dom);
Is parameter $dom passed as a reference or as a copy?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In PHP5, objects are passed by reference. Well, not exactly in technical way, because it’s a copy – but object variables in PHP5 are storing object IDENTIFIER, not the object itself, so essentially it’s the same as passing by reference.
More here:
http://www.php.net/manual/en/language.oop5.references.php