- get_defined_vars: documentation ( source)
- var_export: documentation ( source)
<?php
function f() {
$arr = ['u' => 'U'];
$x = 'x';
$y = 'y';
$result = (fn () => [$x, $x = 'xx', $x, $y, $arr, $arr['w'] = 'W', $arr, $newvar = 'newvar'])();
var_export(get_defined_vars());
}
f();