case 1: return $this->{$method}($args[0]); break; case 2: return $this->{$method}($args[0], $args[1]); break; default: return call_user_func_array([$this, $method], $args); } } public function doSomething($code, $language) { return $code . $language; } } $a = new AClass(); $benchmarks = []; $benchmarks['direct'] = function ($iterations) use($a) { for ($i = 0; $i < $iterations; ++$i) { $value = $a->doSomething('Poland', 'Polish'); if ($value != 'PolandPolish') { throw new Exception('WTF!'); } } }; $benchmarks['cached'] = function ($iterations) use($a) { for ($i = 0; $i < $iterations; ++$i) { $value = $a->doSomethingC('Poland', 'Polish'); if ($value != 'PolandPolish') { throw new Exception('WTF!'); }
<?php error_reporting(-1); ini_set('display_errors', 'On'); require_once '../../lib/ClassLoader.php'; AClass::aFunction(); echo '<br />'; SubClass::SubFunction();
<?php $object = new AClass(); $object->aMethod();
<?php AClass::aStaticMethod();
function __construct() { echo "in Sub class\n"; parent::__construct(); }