note 41470 added to language.types.string
| From: | atnak at chejz dot com | Date: | Sun, 11 Apr 2004 19:53:50 +0000 |
| Subject: | note 41470 added to language.types.string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-67986@lists.php.net to get a copy of this message | ||
Here is a possible gotcha related to oddness involved with accessing strings by character past the
end of the string:
$string = 'a';
var_dump($string{2}); // string(0) ""
var_dump($string{7}); // string(0) ""
$string{7} === ''; // TRUE
It appears that anything past the end of the string gives an empty string.. However, when E_NOTICE
is on, the above examples will throw the message:
Notice: Uninitialized string offset: N in FILE on line LINE
This message cannot be specifically masked with @$string{7}, as is possible when $string itself is
unset.
isset($string{7}); // FALSE
$string{7} === NULL; // FALSE
Even though it seems like a not-NULL value of type string, it is still considered unset.
----
Manual Page -- http://www.php.net/manual/en/language.types.string.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+41470
Delete -- http://master.php.net/manage/user-notes.php?action=delete+41470&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+41470&report=yes
Search -- http://master.php.net/manage/user-notes.php