Take a look at this code (you can execute it):
error_reporting (E_ALL);
function byVal( $v) {}
function byRef(&$v) {}
print '<pre>';
byVal ($first['inexistent_ind ex']); // gives a notice
var_dump($first ); // gives a notice
print '<hr />';
byRef ($second['inexistent_ind ex']); // does NOT give a notice
var_dump($secon d); // does NOT give a notice
print '<hr />';
isset($third); // does NOT give a notice
var_dump ($third); // gives a notice
print '</pre>';
In the $first case, using byVal(), I get *two* notices.
In the $second case, using byRef(), I get *zero* notice.
In the $third case, using isset(), I get *one* notice.
This means that:
1) byVal() does NOT define the array and raises a notice
(and var_dump() raises another notice).
2) byRef() defines the array and does NOT raise notices
(neither var_dump() raises a notice, since $second is defined).
3) isset() does NOT define the array and does NOT raise notices
(but var_dump() raises a notice, since $third is NOT defined).
As you can see, isset() is weird, and I need to emulate its behaviour.
The question is: is it possible to do that in PHP?
Greetings, Giovanni
Comment