PHP VERSION: 8.2.18

abstract_syntax_tree_obj_by_reference.php

<?php 
// by-reference: left-to-right or right-to-left

$obj = new stdClass;
$obj->= &$obj->b;
$obj->1;
var_dump($obj);
/*
    // PHP 5.6 and below
    object(stdClass)#1 (2) {
    ["b"]=>
    &int(1)
    ["a"]=>
    &int(1)
    }
    
    // PHP7
    object(stdClass)#1 (2) {
    ["a"]=>
    &int(1)
    ["b"]=>
    &int(1)
    }
*/

Output


object(stdClass)#1 (2) {
  ["b"]=>
  &int(1)
  ["a"]=>
  &int(1)
}
SOURCE CODE