Here is a demonstration of what is happening to an object member while changing it. This should help you clarify how PHP handles pointers:
class A {
public $val;
public function __construct( $val ) {
$this->val = $val;
}
}
class B {
public $val;
public function __construct( $val ) {
$this->val = $val;
}
}
$a = new A(5);
echo $a->val; // 5
echo "
";
$b = $a;
$b->val = 10;
echo $a->val; // 10
$c = clone( $a );
$c->val = 15;
echo "
";
echo $c->val; // 15
echo "
";
echo $a->val; // 15
echo "
";
$z = 1;
echo ++$z * $z++ + $z; // 7
echo "
";
echo $z; // 3
echo "
";
$m = 0;
do {
echo $m;
} while ( ++$m < 10 );
No comments:
Post a Comment