HI everyone,

i'm studying for the zce exam and i found a blog that try to answer some
questions covered in the exam. I found one that i do not agree.

Question: What is wrong with the following code?

function duplicate($obj) {
$newObj = $obj;
return $newObj;

$a = new MyClass();

$a_copy = duplicate($a);




1. You must use return &$newObj instead
2. There is nothing wrong with this code
3. duplicate() must accept its parameter by reference
4. You must use the clone operator to make a copy of an object
5. duplicate() must return a reference

I  think the answer is the number 4 and not 3 because variable referenced in
php 5 is parsed by reference. Am i right?


Augusto Morais

Reply via email to