Re: empty function and array indices
| From: | Rasmus Lerdorf | Date: | Sun, 01 May 2005 21:35:12 +0000 |
| Subject: | Re: empty function and array indices | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-214300@lists.php.net to get a copy of this message | ||
Gabriel Birke wrote:
Hello! Suppose I have the following code: $a = array('a'=>1, 'b'=>2); echo empty($a['c'])?'empty':'not empty'; echo $a['c']; Why doesn't the 2nd line output a warning when error_reporting is set to E_ALL? Is empty() some kind of special function where the validity of indices is not checked? If that is the case, I have two questions:
1. Will this behavior persist in future versions of PHP?Sure
2. Are there other functions or a general rule where PHP doesn't output warnings when a nonexistant index is given?isset() as well for obvious reasons. -Rasmus