Question:What is wrong with the following code?
<?php

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

$a = new MyClass();

$a_copy = duplicate($a);

$a->setValue(10);
$a_copy->setValue(20);

?>
 

A You must use return &$newObj instead 

B There is nothing wrong with this code 

C duplicate() must accept its parameter by reference 

D You must use the clone operator to make a copy of an object 

E duplicate() must return a reference 

+ Answer
+ Report
Total Preview: 6134

Copyright © 2024. Powered by Intellect Software Ltd