DEV Community

Discussion on: 45 Important PHP Interview Questions That May Land You a Job

Collapse
 
kor3k profile image
kor3k

Q15 - In PHP, objects passed by value.

that is not correct.

"As of PHP 5, an object variable doesn't contain the object itself as value anymore. It only contains an object identifier which allows object accessors to find the actual object. When an object is sent by argument, returned or assigned to another variable, the different variables are not aliases: they hold a copy of the identifier, which points to the same object."

so it's neither value nor reference, but "object handle", which is a pointer under the hood.