本文整理汇总了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));
}
示例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);
}
示例3: test
function test()
{
$x = 0;
foreach (gen($x) as $y) {
var_dump($y);
}
var_dump($x);
}
示例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);
}
}
示例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--;
}
}
示例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;
}
示例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);
}
示例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";
}
示例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;
}
示例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();
}
}
示例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 $_) {
}
示例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('ЮПА-СТАЙЛ!');
示例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===