<?php
function struct(string $name, array $class) {
$class = json_encode($class);
define($name, $class);
}
function create($class) {
$object = (array) json_decode($class);
return $object;
}
function call(array &$class, string $member, ...$args) {
if(!isset($class[$member])) exit($member.' is not a member of the class.');
else {
if(!isset($args[0])) call_user_func([$class, $member], $class);
else call_user_func([$class, $member], $class, $args);
}
}
$obj = [
'foo' => function (&$this) {
echo('Hello World!');
}
]
call($obj, 'foo');
- Output for 5.6.8 - 5.6.16, 7.0.0 - 7.0.1
- Parse error: syntax error, unexpected 'call' (T_STRING) in /in/mhc82 on line 23
Process exited with code 255. - Output for 5.5.24 - 5.5.30
- Parse error: syntax error, unexpected '.', expecting '&' or variable (T_VARIABLE) in /in/mhc82 on line 10
Process exited with code 255.
preferences:
158.97 ms | 1395 KiB | 25 Q