note 73165 deleted from language.types.array by tularis
| From: | tularis@php.net | Date: | Sun, 11 Feb 2007 23:25:08 +0000 |
| Subject: | note 73165 deleted from language.types.array by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-123262@lists.php.net to get a copy of this message | ||
Note Submitter: Andrei Railean (www.andrei.md)
Reason: bad code
----
A simple way to suppress 'undefined index' errors is the same as for function calls -
prefix array access with the @ sign.
<?php
$array = Array();
$b = @$array['b'];
if (is_null($b)) {
echo "b is null";
}
?>
Will output 'b is null' without an error.
Handy for deep/dynamic arrays