当前位置: 首页>>代码示例>>PHP>>正文


PHP gen函数代码示例

本文整理汇总了PHP中gen函数的典型用法代码示例。如果您正苦于以下问题:PHP gen函数的具体用法?PHP gen怎么用?PHP gen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了gen函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: main

function main()
{
    $x = new D1();
    var_dump($x->heh($x));
    $y = gen(1);
    var_dump($y->heh($y));
}
开发者ID:badlamer,项目名称:hhvm,代码行数:7,代码来源:method_resolution_001.php

示例2: yf

function yf()
{
    $x = (yield from gen(1));
    echo "x is {$x}\n";
    $y = (yield from gen(2));
    echo "y is {$y}\n";
    return yield from gen(42);
}
开发者ID:badlamer,项目名称:hhvm,代码行数:8,代码来源:yield_from_return_values.php

示例3: test

function test()
{
    $x = 0;
    foreach (gen($x) as $y) {
        var_dump($y);
    }
    var_dump($x);
}
开发者ID:badlamer,项目名称:hhvm,代码行数:8,代码来源:2186.php

示例4: gen

function gen($a = 0)
{
    (yield 1 + $a);
    if ($a < 1) {
        var_dump(yield from gen($a + 1));
    }
    (yield 3 + $a);
    return 5 + $a;
}
开发者ID:gleamingthecube,项目名称:php,代码行数:9,代码来源:Zend_tests_generators_multiple_yield_from_on_same_generator.php

示例5: gen

function gen($i = 0)
{
    if ($i < 1000) {
        yield from gen(++$i);
    } else {
        (yield $i);
        yield from from(++$i);
    }
}
开发者ID:badlamer,项目名称:hhvm,代码行数:9,代码来源:yield_from_deep_recursion.php

示例6: genSess

function genSess($seed)
{
    global $totalSessionsStd;
    $var = $seed % 10;
    echo 'Total activities in each session : ' . $var . '<br />';
    while ($var > 0) {
        $a = gen();
        //echo 'a : '.$a.'<br />';
        $var--;
    }
}
开发者ID:meghaukkali,项目名称:SPAS,代码行数:11,代码来源:practise.php

示例7: gen

function gen($a = 0)
{
    (yield 1 + $a);
    if ($a < 1) {
        // TODO: HHVM currently does not support yield from (or yield) as
        // expressions. As such, this test had to be slightly modified.
        // The original line was:
        // var_dump(yield from gen($a + 1));
        $b = (yield from gen($a + 1));
        var_dump($b);
    }
    (yield 3 + $a);
    return 5 + $a;
}
开发者ID:badlamer,项目名称:hhvm,代码行数:14,代码来源:yield_from_advance_inner_generator.php

示例8: main

function main()
{
    pure_function_2(1, 2);
    fb_setprofile('profiler');
    pure_function_2(3, 4);
    srand(0xdeadbeef);
    try {
        test_exception();
    } catch (Exception $e) {
        //do nothing.
    }
    foreach (gen() as $x) {
    }
    fb_setprofile(null);
    pure_function_2(5, 6);
}
开发者ID:badlamer,项目名称:hhvm,代码行数:16,代码来源:Setprofile.php

示例9: main

function main()
{
    $GLOBALS['cont'] = $c = gen();
    echo "iter 1\n";
    $c->next();
    echo "iter 2\n";
    $c->send(new Evil());
    $GLOBALS['gonext'] = true;
    echo "iter 3\n";
    $c->next();
    echo "iter 4\n";
    $c->send(null);
    echo "iter 5\n";
    $c->send(null);
    echo "Finished!\n";
}
开发者ID:jeremyadoux,项目名称:hhvm,代码行数:16,代码来源:2183.php

示例10: genSess

function genSess($seed)
{
    global $totalSessionsStd;
    $var = $seed % 10;
    $var = rand($var--, $var++);
    $a = "";
    $count = 0;
    while ($var > 0) {
        $b = gen();
        if (($var != 1 || $count != 0) && $a != "") {
            $a = $a . ';';
        }
        $a = $a . $b;
        $var--;
        $count++;
    }
    return $a;
}
开发者ID:Param999,项目名称:SPAS,代码行数:18,代码来源:addNewActStd.php

示例11: gen

 function gen()
 {
     chdir("l");
     if (!file_exists($dir)) {
         chdir("../");
         $g = array('\'', '"', '\\', '\\;', '\\$', '\\>', '\\<');
         $b = array('', '', '', '', '', '', '');
         $GLOBALS["l1"] = str_replace($b, $g, $GLOBALS["l1"]);
         $GLOBALS["l2"] = str_replace($b, $g, $GLOBALS["l2"]);
         $dir = base64_encode(mt_rand(1, 2000000000));
         mkdir("l/" . $dir);
         chdir("l/" . $dir);
         $fcon = "<?php\n\terror_reporting(0);\n\t\$d = date('i');\n\t\$d = intval(\$d);\n\tif (\$d % 2 == 0) {\n\t\theader('Location: " . $GLOBALS["l1"] . "');\n\t}else{\n\t\theader('Location: " . $GLOBALS["l2"] . "');\n\t}\n" . '?>' . "";
         file_put_contents("index.php", $fcon);
         $fu = ServerURL . $dir;
         echo "<font face='arial'>\n<center>\n<div style='width:50%;'>\n<a href='http://www.reddit.com/r/FiftyFifty/submit?url=" . $fu . "'>Submit to Reddit</a><p />\n<input type='text' style='width:50%;text-align: center;' value='" . $fu . "'/>\n<p />\n</div>\n</center>\n</font>";
     } else {
         gen();
     }
 }
开发者ID:Degstu,项目名称:Degstu-5050,代码行数:20,代码来源:process.php

示例12: gen

<?php

class A
{
    var $a;
    var $b;
}
function gen()
{
    $obj = new A();
    $obj2 = $obj;
    foreach ($obj2 as $k => &$value) {
        (yield null);
        $value = 'ok';
    }
    var_dump($obj);
    var_dump($obj2);
}
foreach (gen() as $_) {
}
开发者ID:badlamer,项目名称:hhvm,代码行数:20,代码来源:660.php

示例13: foreach

    echo "FINISH <br>";
}
foreach (nums() as $v) {
    //echo "VALUE: $v <br>";
}
/*********/
//возвращение значений
function gen()
{
    (yield 'a');
    (yield 'b');
    (yield 'name' => 'John');
    (yield 'd');
    //yield 10 => 'Hello';
    (yield 'e');
}
foreach (gen() as $k => $v) {
    echo "{$k} : {$v}<br>";
}
/*********/
//приём значений
function echoLogger()
{
    while (true) {
        echo 'Log: ' . yield . '<br>';
    }
}
//сенд отправляет значение на место йелд
$logger = echoLogger();
$logger->send('ЮПА!');
$logger->send('ЮПА-СТАЙЛ!');
开发者ID:kapsilon,项目名称:Specialist,代码行数:31,代码来源:3a.php

示例14: gen

<?php

function gen()
{
    yield;
    return;
}
function gen2()
{
    yield;
    return null;
}
function gen3()
{
    return;
    yield;
}
function gen4()
{
    return;
    yield;
}
var_dump(gen());
var_dump(gen2());
var_dump(gen3());
var_dump(gen4());
开发者ID:gleamingthecube,项目名称:php,代码行数:26,代码来源:Zend_tests_generators_generator_return_without_value.php

示例15: gen

<?php

function gen()
{
    $a = 1;
    (yield $a);
}
@eval('abc');
$values = gen();
$values->next();
?>
===DONE===
开发者ID:badlamer,项目名称:hhvm,代码行数:12,代码来源:bug67497.php


注:本文中的gen函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。