- var_dump: documentation ( source)
- settype: documentation ( source)
- print_r: documentation ( source)
- array_pop: documentation ( source)
<?php
// r() simply returns a reference to a given variable.
function &r(&$v){return $v;}
// Here, we have a scalar $a on which settype() fails to operate if
// parentheses are involved.
print "Scalar demonstration:\n";
$a = 1;
// First with parentheses, then without.
// v v
settype( ( r($a) ) , "boolean"); var_dump($a);
settype( r($a) , "boolean"); var_dump($a);
// ^ ^
// Here is a similar situation where array_pop() fails to operate upon a
// reference to an array if parentheses are involved.
print "\nArray demonstration:\n";
$b = array("c");
// First with parentheses, then without.
// v v
array_pop( ( r($b) ) ); print_r($b);
array_pop( r($b) ); print_r($b);
// ^ ^