class Foo
{
    public function __call($method, $args)
    {
        if ($method === 'findSum') {
            echo 'Sum is calculated to ' . $this->getSum($args);
        } else {
            echo "Called method {$method}";
        }
    }
    private function getSum($args)
    {
        $sum = 0;
        foreach ($args as $arg) {
            $sum += $arg;
        }
        return $sum;
    }
}
$foo = new Foo();
$foo->bar1();
// Called method bar1
echo '<br>';
$foo->bar2();
// Called method bar2
echo '<br>';
$foo->findSum(10, 50, 30);
//Sum is calculated to 90
echo '<br>';
$foo->findSum(10.75, 101);
//Sum is calculated to 111.75
示例#2
0
文件: common.php 项目: nextop/forp-ui
forp_inspect('lambda', $lambda);
// calls
for ($i = 0; $i < 1000; $i++) {
    test($i);
    // inspect stress
    // forp_inspect('i' . $i, $i);
}
for ($i = 0; $i < 5; $i++) {
    test1();
}
$lambda();
$lambda();
$foo = new Foo();
//sleep(1);
$foo->bar();
$foo->bar2($lambda, $foo);
forp_inspect('foo', $foo);
/**
 * @ProfileAlias("Alloc")
 */
$alloc = function () {
    $stdObject = new stdClass();
    $stdObject->arr = array();
    for ($i = 0; $i < 100; $i++) {
        $stdObject->arr[$i] = "test";
    }
    return $stdObject;
};
/**
 * @ProfileAlias("test alloc")
 */