I have the simple code:
class A {
public $var = 1;
function inc() {$this->var++;}
}
function foo($a) {
for($i = 0; $i < 10; $i++) {
$a->inc();
}
}
$a = new A();
foo($a);
$v = $a->var;
echo "var value is $v \n";
I was expecting to get printed the value of 1 but I get 11. shouldn't PHP pass argument to functions with copy-constructor?