Re: Accessing string offsets
| From: | Andi Gutmans | Date: | Sun, 11 Nov 2001 18:19:38 +0000 |
| Subject: | Re: Accessing string offsets | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-70148@lists.php.net to get a copy of this message | ||
At 02:02 PM 11/11/2001 +0100, Markus Fischer wrote:
Right now, the following produces a warning when using error_reporting(E_ALL) which can only be catched with ob_start(): <? $string = "foo"; echo $string[3] . "\n"; ?> gives -(1) : Warning - Uninitialized string offset: 3 Is it really necessary to always first check the length before accessing a certain offset? Wouldn't just returning an empty string be enough? I.e., just remove the warning in Zend/zend_execute.c:103 ?I think it actually makes sense to have a warning here.
Btw, is $string{$offset} documented anywhere? Derick already told me its not but then its in PHP since a long time. Is $string{$offset} really faster but not well-tested? I've already even seen it in a PEAR package (Console/Getopt.php from Andrei).It's not documented yet because it hasn't been implemented yet (the syntax is supported but I want to improve it in Zend 2). Andi