PHP VERSION: 8.2.18

anonymous_class.php

<?php

$i 
'TEST';
$obj = new class($i) {
    public function 
__construct($i) {
        
$this->$i;
    }
};

echo 
$obj->i;
var_dump($obj);



Output


TESTobject(class@anonymous)#1 (1) {
  ["i"]=>
  string(4) "TEST"
}
SOURCE CODE