|
Posted by Bent Stigsen on 09/17/05 23:57
Dikkie Dik wrote:
[snip]
> The non-existing variable is evaluated as NULL with a warning, not a
> fatal error. NULL gets cast to an empty string, which is "glued" between
> the 'M' strings. If you don't want the warning, you can temporarily
> switch it off by putting a '@' character in front of the expression or
> the command, like
> @$result=mArray['NonExistingKey'];
> echo 'M' . $result . 'M';
>
> You can use this feature to check if variables exists in a quick-and
> dirty way:
> @$strUrlParameter=$_GET['Command'];
> if(is_null($strUrlParameter))
> ...
[snip]
"isset" can also be used for this, which will suppress warning for
non-existent index. However "isset", or the code ove, will not tell
the difference between, an existing index assigned a NULL-value, and a
non-existing index.
That is probably also the point with accepting a non-existing index as
non-fatal. That is, why enforce a verification of an index, when
validation of its value is just as important. But as it just might be
a mistake, a warning is in order.
/Bent
Navigation:
[Reply to this message]
|