- print_r: documentation ( source)
- test2: documentation ( source)
<?php
function &test($a) {
$empty = array();
return isset($a) ? $a : $empty;
}
function &test2($a) {
$empty = [];
if (isset($a)) {
return $a;
}
else {
return $empty;
}
}
$test =& test('123');
print_r($test);
$test =& test2('123');
print_r($test);
$test =& test(NULL);
print_r($test);
$test =& test2(NULL);
print_r($test);