PHP 8.5.0 Alpha 4 available for testing

Voting

: max(five, eight)?
(Example: nine)

The Note You're Voting On

gevorgmelkoumyan at gmail dot com
6 years ago
I think this example should clarify the difference between PHP references (aliases) and pointers:

<?php

class A {
public
$var = 42;
}

$a = new A; // $a points to the object with id=1
echo 'A: ' . $a->var . PHP_EOL; // A: 42

$b = $a; // $b points to the object with id=1
echo 'B: ' . $b->var . PHP_EOL; // B: 42

$b->var = 5;
echo
'B: ' . $b->var . PHP_EOL; // B: 5
echo 'A: ' . $a->var . PHP_EOL; // A: 5

$b = new A; // now $b points to the object with id=2, but $a still points to the 1st object
echo 'B: ' . $b->var . PHP_EOL; // B: 42
echo 'A: ' . $a->var . PHP_EOL; // A: 5

?>

<< Back to user notes page

To Top