One room, many keys
Assign an object to a second variable and pass it to a function.
<?phpclass Counter{ public int $n = 1;}function bump(Counter $c): void{ $c->n++;}$a = new Counter();$b = $a;$b->n = 5;echo 'a: ', $a->n, PHP_EOL;bump($a);echo 'a: ', $a->n, PHP_EOL;echo $a === $b ? 'same room' : 'two rooms', PHP_EOL;1. Predict the output
Tap the lines in the order you think they print.
- 1…
- 2…
- 3…