@ 2016-01-05T17:55:09Z <?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));
}
}
struct('myStruct', [
'foo' => 'Hello World!',
'bar' => function (&$this) {
echo(' Hi!');
}
]);
$obj = create(myStruct);
call($obj, 'bar');
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 7.0.1 0.003 0.093 20.33 7.0.0 0.010 0.063 20.22 5.6.16 0.007 0.067 20.55 5.6.15 0.000 0.060 18.27 5.6.14 0.003 0.053 18.26 5.6.13 0.000 0.063 18.21 5.6.12 0.013 0.077 20.97 5.6.11 0.003 0.053 21.20 5.6.10 0.007 0.063 21.00 5.6.9 0.007 0.050 21.07 5.6.8 0.010 0.030 20.29 5.5.30 0.013 0.073 17.99 5.5.29 0.010 0.063 17.94 5.5.28 0.007 0.087 20.97 5.5.27 0.013 0.037 20.88 5.5.26 0.013 0.080 20.80 5.5.25 0.007 0.077 20.58 5.5.24 0.020 0.040 20.12
preferences:dark mode live preview
125.63 ms | 1398 KiB | 7 Q