function __construct() { echo __METHOD__, "\n"; } } namespace Fiz\Biz\Buz; use Foo\Bar\Baz\{A, B, C as AC, D, function foo, function bar as buz, const FOO, const BAR as BOZ}; class C { function __construct() { echo __METHOD__, "\n"; } } function bar() { echo __FUNCTION__, "\n"; } const BAR = 100; new A(); new B(); new AC(); new D(); new C(); foo(); buz(); bar(); var_dump(FOO); var_dump(BOZ); var_dump(BAR);
<?php $a = array(1, 2, 3, 4, 5); function foo($a, $b, $c) { var_dump('foo'); return 1; } function bar($a, $b, $c) { var_dump('bar'); return 2; } function buz($x, $y) { if ($y) { return $x; } return 1; } $s = buz('hello', 1); foreach ($a as $s[3]) { var_dump($s); } $i = 0; foreach ($a as $a[bar($i++, $i++, $i++)] => &$a[foo($i++, $i++, $i++)]) { var_dump($a[1], $a[2]); } foreach ($a as $a[bar($i++, $i++, $i++)] => $a[foo($i++, $i++, $i++)]) { var_dump($a[1], $a[2]); }
<?php $foo = 123; function &baz() { global $foo; return $foo; } function bar() { $baz = 'baz'; return $baz(); } function buz() { global $foo; return $foo; } $a =& bar(); $a = 456; var_dump($a, $foo); $a =& buz(); $a = 789; var_dump($a, $foo);