function five() { (yield 1); (yield 2); yield from two(); return 5; }
function main() { one(1); two(1); three(1); set_error_handler('error_handler'); one(1); two(1); three(1); }
<?php // def_alias - создаёт алиас для функции. def('one', function () { echo 1; }); def_alias('one', 'two'); one(); two(); ?> --- 11
function one(&$foo, $bar) { $foo = 9; $bar = 10; $bar =& $foo; $bar = 11; } one($bar, $foo); echo "4bar: {$bar}, foo: {$foo}\n"; function two($bar, &$zot) { $zot = 12; $bar =& $zot; $zot = 13; } two($bar, $zot); echo "5foo: {$foo}, bar: {$bar}, zot: {$zot}\n"; function three($zot, $foo) { $zot =& $foo; $foo =& $foo; $bar =& $foo; $zot =& $bar; $bar++; } function four(&$zot, &$foo) { //this screws up zend's implementation. // $foo =& $foo; $foo++; }
$this->author = $author; $this->date = $date; $this->messageid = $messageid; $this->idlist = $idlist; } } # class Spotinfo $objList = array(); $arList = array(); $y = microtime(true); for ($i = 0; $i < 10000; $i++) { $x = new Dto('title', 'author', '01 april 2012', '<*****@*****.**>', array('<*****@*****.**>')); $objList[] = $x; } # for echo 'Object run time: ' . (microtime(true) - $y) . PHP_EOL; $y = microtime(true); for ($i = 0; $i < 10000; $i++) { $x = array('title' => 'title', 'author' => 'author', 'date' => '01 april 2012', 'messageid' => '<*****@*****.**>', 'idlist' => array('<*****@*****.**>')); $arList[] = $x; } # for echo 'Array run time: ' . (microtime(true) - $y) . PHP_EOL; $x = str_repeat('aaaaa', 12 * 1024); $y = array($x, $x, $x); $y = microtime(true); one($x); echo 'Passing not per reference: ' . (microtime(true) - $y) * 1000 . PHP_EOL; $y = microtime(true); two($x); echo 'Passing per reference: ' . (microtime(true) - $y) * 1000 . PHP_EOL;
/** * Simple method to illustrate parameter passing with primitive types. * @ignore */ function one() { $y = 1; printf("%s\n", $y); two($y); printf("%s\n", $y); }
function ms2time($ms) { if ($ms < 0) { $ms *= -1; } $sec = floor($ms / 1000); $ms = $ms % 1000; $ms = three($ms); $min = floor($sec / 60); $sec = $sec % 60; $sec = two($sec); $hr = floor($min / 60); $min = $min % 60; $min = two($min); $day = floor($hr / 60); $hr = $hr % 60; $hr = two($hr); return array($hr, $min, $sec, $ms); }
/** * FileName note.php. * User: yangzie1192@163.com * Version:0.1 * Date: 2015/12/19 * Time: 18:19 */ function one($str1, $str2) { two("Glenn", "Quagmire"); }