PHP returns Call to undefined method stdClass::fragmentr()
for the following code:
$core = new \StdClass;
$core->fragmentr = function($frag) {
$path = sprintf("fragments/%s.php", $frag);
if(is_file($path)) {
include $path;
} else {
header("Location: ./?p=500");
exit;
}
}
/* SNIP */
$core->fragmentr('header');
However, the function $core->fragmentr is clearly defined as an anonymous function assigned to a variable. Any ideas?