- var_dump: documentation ( source)
- sprintf: documentation ( source)
<?php
function anon()
{
static $i = 0;
return eval(sprintf('return new class { public $prop%s; };', ++$i));
}
$c1 = anon();
$c1->prop1 = 'hello';
$c2 = anon();
var_dump($c1, $c2, $c1->prop1, $c1->prop2);