function main() { f1(); f2(); f3(); f4(); f5(); f6(); f7(); f8(); }
$out_f5 = f5(); var_dump($out_f5); // int(2) $out_f5 = 10; var_dump($out_f5); // int(10) $out_f5 = f5(); var_dump($out_f5); // int(3) $out_f5 =& f5(); var_dump($out_f5); // int(4) $out_f5 = 10; var_dump($out_f5); // int(10) $out_f5 = f5(); var_dump($out_f5); // int(11) [**] /* * actual_paramter ::= '&' VARIABLE * * Note the discrepency between this and the previous test. * - If a function _returns_ a symbol table entry, the associated assignment * must also be =& (and not just =; cf. test above) * - For a function to _accept_ a symbol table entry, there is a choice: * either you add the & to the formal parameter, or you add the & to the * actual parameter (both is allowed too). */ function h1($in_h1) { $in_h1++;
var_dump($k, $v); } } function f5($x) { switch ($x[0]) { case 0: var_dump($x[0]); } } function f6($x, $y, $z) { if ($z) { goto my_clause; } if ($y) { var_dump($y); } else { if ($x[0]) { var_dump($x[0]); my_clause: var_dump($x); } } } f1(array(0, 0)); f2(array(10)); f3(array(10), false); f4(array(array(1, 2, 3))); f5(array(false, false)); f6(array(true), false, false);
__var_dump($c); __var_dump(get_defined_vars()); } function f3() { $a = 1; $c = extract(array("a" => 1), EXTR_PREFIX_ALL, "prefix"); echo "Extracted:"; __var_dump($c); __var_dump(get_defined_vars()); } function f4() { $c = extract(array("" => 1), EXTR_PREFIX_ALL, "prefix"); echo "Extracted:"; __var_dump($c); __var_dump(get_defined_vars()); } function f5() { $c = extract(array("111" => 1), EXTR_PREFIX_ALL, "prefix"); echo "Extracted:"; __var_dump($c); __var_dump(get_defined_vars()); } f1(); f2(); f3(); f4(); f5();
function f3() { f4(); f5(); }
class D2 extends C2 implements I2 { } function f4(I1 $p1) { echo "Inside " . __METHOD__ . "\n"; var_dump($p1); } //f4(123); // must implement interface I1, integer given f4(new C2()); f4(new D2()); echo "--------------- test type hint callable ---------------------\n"; function hello() { echo "Hello!\n"; } function f5(callable $p1) { echo "Inside " . __METHOD__ . "\n"; var_dump($p1); $p1(); } //f5(123); // must be callable, integer given f5('hello'); echo "--------------- test type hint + by ref ---------------------\n"; function f6(C1 &$p1) { echo "Inside " . __METHOD__ . "\n"; var_dump($p1); } f6(new C1());
if (!isset($hide_files)) { $hide_files = "skin.xml,wimpyConfigs.xml"; } if (!isset($wimpyHTMLpageTitle)) { $wimpyHTMLpageTitle = "Wimpy Player"; } if ($ecommerce == "yes") { $forceDownload = "no"; $displayDownloadButton = "yes"; $getMyid3info = "yes"; } $v106 = true; $v80 = 0; $v79 = 0; if (strlen(@$wimpySkin) > 4) { if ($v40 = f5($wimpySkin)) { $v114 = @xml_parser_create(''); @xml_parse_into_struct($v114, $v40, $v109, $v56); @xml_parser_free($v114); $v80 = @$v109[@$v56['BKGD_MAIN'][0]]['attributes']['WIDTH']; $v79 = @$v109[@$v56['BKGD_MAIN'][0]]['attributes']['HEIGHT']; } else { $v106 = false; } } else { $v106 = false; } if ($v80 < 1 || $v79 < 1) { $v106 = false; $v80 = "480"; $v79 = "140";
function f2($x) { if ($x[0]) { var_dump(id($x), $x[0]); } } f2(null); f2(array()); f2(array(10)); function f3($x) { var_dump($x[0] . '/' . $x[1]); var_dump($x[0] . '/' . $x[1]); } f3(array('first', 'second')); f3('AB'); function f4($x) { $z = @id($x[0]); var_dump($z); var_dump($x[0]); } f4(array('e1', 'e2')); function f5($x) { if ($x[0][id($x[0]) - 1]) { var_dump($x); } } f5(array(0, 1, 2));
function f18($v8) { $v10 = array(); for ($i = 0; $i < sizeof($v8); $i++) { $v75 = $v8[$i]; if (strtolower(substr($v75, 0, 4)) == "file") { $v17 = explode("=", $v75); $v18 = explode("=", $v8[$i + 1]); $v19 = explode("=", $v8[$i + 2]); $v33 = array(); $v33['filename'] = $v17[1]; $v33['artist'] = ""; $v33['album'] = ""; $v33['title'] = $v18[1]; $v33['track'] = ""; $v33['comments'] = ""; $v33['genre'] = ""; $v33['seconds'] = $v19[1]; $v33['filesize'] = ""; $v33['bitrate'] = ""; $v33['visual'] = ""; $i++; $i++; $v10[sizeof($v10)] = $v33; } } f5($v10); }
function bar() { $a = 1; f1($a, $a, $a); var_dump($a); $a = 1; f2($a, $a, $a); var_dump($a); $a = 1; f3($a, $a, $a); var_dump($a); $a = 1; f4($a, $a, $a); var_dump($a); $a = 1; f5($a, $a, $a); var_dump($a); $a = 1; f6($a, $a, $a); var_dump($a); $a = 1; f7($a, $a, $a); var_dump($a); $a = 1; f8($a, $a, $a); var_dump($a); }
{ $y = (double) $x; var_dump($y); return $y; } var_dump(f1()); var_dump(f2()); var_dump(f3()); var_dump(f4()); var_dump(f5()); var_dump(f6()); var_dump(f1(null)); var_dump(f2(null)); var_dump(f3(null)); var_dump(f4(null)); var_dump(f5(null)); var_dump(f6(null)); function rf1($x) { if ($x) { return 'f1'; } return 0; } function rf2($x) { if ($x) { return 'f2'; } return 0; }
} var_dump($x[0]); } f2(array(0 => array())); f2(array()); f2(''); f2($o); f2(null); function f3($x) { foreach ($x['foo'] as $k => $v) { if ($v) { unset($x['foo'][$k]); } } var_dump($x); } f3(array('foo' => array(0, 1, 2, 3))); function f4($x) { var_dump($x[0][1]); unset($x[0][1]); var_dump($x[0][1]); } f4(array(array(1 => new stdClass()))); function f5($x) { var_dump(md5($x[0]), $x[0]); } f5('foobar');
<?php function f5() { $i = 0; $foo = array('f' => 3, 'e' => 1, 'd' => 5, 'a' => 6, 'b' => 2, 'c' => 4); $a = 0; foreach ($foo as $key => &$val) { (yield null); echo "key={$key} val={$val}\n"; if ($key == 'e' && $a == 0) { $a = 1; unset($foo['e']); unset($foo['d']); $foo['d'] = 9; for ($j = 0; $j < 10000; ++$j) { $foo[$j . 's' . $j] = $j; } } ++$i; if ($i >= 20) { break; } } } foreach (f5() as $_) { }
function f2($a, $b) { print $a; print $b; } f2($HTTP_RAW_POST_DATA, $http_raw_post_data); function f3($a, $b) { echo $a; echo $b; } f3($_SERVER['DOCUMENT_ROOT'], $_SERVER['QUERY_STRING']); function f4($a, $b) { print $a; print $b; } f4($_SERVER['DOCUMENT_ROOT'], $_SERVER['QUERY_STRING']); // Those are called with safe functions. function f5($a, $b) { strtolower($a); strtolower($b); } f5($_SERVER, $_SERVER); function f6($a, $b) { strtolower($a); strtolower($b); } f6($_SERVER['DOCUMENT_ROOT'], $_SERVER['QUERY_STRING']);