public function index()
 {
     function bar($x)
     {
         if ($x > 0) {
             bar($x - 1);
         }
     }
     function foo()
     {
         for ($idx = 0; $idx < 5; $idx++) {
             bar($idx);
             $x = strlen("abc");
         }
     }
     //开启调试
     xhprof_enable();
     // cpu:XHPROF_FLAGS_CPU 内存:XHPROF_FLAGS_MEMORY
     // 如果两个一起:XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY
     xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
     //要测试的php代码
     foo();
     //停止监测
     $xhprof_data = xhprof_disable();
     // display raw xhprof data for the profiler run
     print_r($xhprof_data);
     //包含工具类,在下载的 tgz 包中可以找到
     //$XHPROF_ROOT = realpath(dirname(__FILE__) .'/..');
     Vendor('Xhprof.autoload');
     //Vendor('Xhprof.xhprof_runs');
     //include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_lib.php";
     //include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_runs.php";
     // save raw data for this profiler run using default
     // implementation of iXHProfRuns.
 }
Example #2
0
function go()
{
    foo(new dtor(1), new dtor(2));
    foo(new dtor(3), new dtor(4));
    foo(new dtor(5), new dtor(6));
    foo(new dtor(7), new dtor(8));
}
Example #3
0
function test($x, $a)
{
    $x = foo($a);
    if ($x) {
        $x->foo();
    }
}
Example #4
0
function bar()
{
    $k = "asd";
    $z =& $k;
    $y = foo();
    echo $z;
}
Example #5
0
 public static function bar($str)
 {
     switch ($str) {
         case "specific":
             echo "in specific case";
             break;
         case "common_1":
         case "common_2":
             echo "in common case";
             break;
         case "fallthrough":
             echo "will fall through";
             // FALLTHROUGH
         // FALLTHROUGH
         case "dummy":
             echo "dummy case";
             break;
         default:
             echo "I guess this is the end, my friend";
     }
     echo "\n";
     $y = true;
     $z = 41;
     switch (true) {
         case foo($str):
             echo "helloooo";
             break;
         case $y && $z + 1 == 42:
             echo "nevermind";
             break;
     }
     echo "\n";
 }
Example #6
0
function main()
{
    $x = throwFromCallee(1);
    var_dump($x);
    $x = foo(2);
    var_dump($x);
}
Example #7
0
function bar($a, $b)
{
    if ($a) {
        $value = $a * foo(1, 2);
    }
    return 1 / $b;
}
function testRuleNotAppliesToShortVariableNameInCatchStatement()
{
    try {
        foo();
    } catch (Exception $e) {
    }
}
Example #9
0
function bar()
{
    for ($i = 0; $i < 4; $i++) {
        if ($i > 1 && !function_exists('foo')) {
            function foo()
            {
                echo "foo called\n";
            }
        }
        $foo = 'foo';
        if (function_exists($foo)) {
            foo();
        } else {
            echo "foo does not exists\n";
        }
    }
    for ($i = 0; $i < 4; $i++) {
        if ($i > 1 && !class_exists('goo')) {
            class goo
            {
                function goo()
                {
                    echo "goo called\n";
                }
            }
        }
        $goo = 'goo';
        if (class_exists($goo)) {
            $a = new goo();
        } else {
            echo "goo does not exists\n";
        }
    }
}
Example #10
0
function bar()
{
    $x = foo();
    $x[123] = 2;
    $x['asdasdasd'] = new stdclass();
    return $x;
}
Example #11
0
function test()
{
    $a = foo(1);
    $a = foo($a);
    $a = foo($a);
    print_r($a, true);
}
Example #12
0
function bar()
{
    $x = foo();
    $x->heh();
    $x->heh();
    return $x;
}
Example #13
0
function main()
{
    $x = foo(array(1, 2, 3));
    foreach ($x as $k => $v) {
        var_dump($v);
    }
}
Example #14
0
function foo($lv = 1, $iNodeId = 1, $limit, $showallart, $oAN, $oMAI, &$tmp, $setting)
{
    if ($lv < 0) {
        return;
    }
    $aNodes = $oAN->get_nodes($iNodeId);
    if (is_array($aNodes)) {
        foreach ($aNodes as $val) {
            if ($val['ifpub'] == 'false') {
                continue;
            }
            foo($lv - 1, $val['node_id'], $limit, $showallart, $oAN, $oMAI, $tmp['child'][$val['node_id']], $setting);
            if (empty($tmp['child'][$val['node_id']])) {
                unset($tmp[$val['node_id']]);
            }
            $tmp['child'][$val['node_id']]['info'] = $val;
        }
    }
    if ($showallart) {
        if (!$limit) {
            return;
        }
        #if( $lv==$setting['lv'] ) return false;
        $tmp['article'] = $oMAI->getList_1('*', array('node_id' => $iNodeId, 'ifpub' => 'true', 'nochildren' => true), 0, $limit);
    }
}
Example #15
0
function bar()
{
    foo(1);
    3;
    foo(1);
    4;
}
Example #16
0
function foo($p)
{
    if ($p) {
        foo($p);
    }
    echo $p;
}
Example #17
0
function bar()
{
    $x = foo();
    foreach ($x as $k) {
        echo $k;
        echo "\n";
    }
}
Example #18
0
File: 65.php Project: badlamer/hhvm
function test3()
{
    if (foo(0)) {
        $a = 1;
    }
    $x = new StdClass();
    return $a::foo;
}
Example #19
0
function bar($seconds)
{
    $bar = str_repeat('telltale', rand(1111, 99999));
    if ($seconds > 0) {
        sleep(rand($seconds - 1, $seconds + 1));
        foo($seconds - 1);
    }
}
Example #20
0
function main()
{
    try {
        foo();
    } catch (Exception $e) {
        echo "Caught exception\n";
    }
}
Example #21
0
 function quatz(TestCase $tc)
 {
     let('result')->be(6 * 6);
     $tc->assertEquals(get('result'), '36');
     foo($tc);
     bar($tc);
     $tc->assertEquals(get('result'), '36');
 }
Example #22
0
function main()
{
    $x = foo();
    echo $x['other']['foo']['heh'] . "\n";
    echo $x['other']['whatever'] . "\n";
    var_dump($x['yoyo']['stuff']['other']['foo']['heh']);
    var_dump($x['yoyo']['stuff']);
}
Example #23
0
function main()
{
    var_dump(foo());
    var_dump(bar());
    fb_rename_function('bar', 'baz');
    fb_rename_function('foo', 'bar');
    var_dump(bar());
}
Example #24
0
function test($a, $b, $c, $d, $e)
{
    $k = array();
    foreach ($a as $id) {
        $k[$id] = foo($id, $b, $c, $d, $e);
        $k[$id] = foo($k[$id], $b);
    }
}
Example #25
0
function quatz()
{
    let('result')->be(6 * 6);
    print __METHOD__ . ' -- result: ' . get('result') . PHP_EOL;
    foo();
    bar();
    print __METHOD__ . ' -- result: ' . get('result') . PHP_EOL;
}
Example #26
0
function test()
{
    try {
        foo();
    } catch (Exception $e) {
    }
    var_dump('ok');
}
function foo($x)
{
    if ($x == 10) {
        return 0;
    } else {
        return $x + foo($x + 1);
    }
}
function foo()
{
    if ($_GET["test"]) {
        foo();
    } else {
        echo $_GET["usr"];
    }
}
Example #29
0
function foo($x)
{
    if ($x > 1) {
        $y = $x - 1;
        foo($y);
    }
    echo "{$x}\n";
}
Example #30
0
function runfoo()
{
    $start = memory_get_usage(true);
    for ($i = 0; $i < 10; $i++) {
        foo();
    }
    $end = memory_get_usage(true);
    return $end - $start;
}