note 90369 added to function.substr
| From: | webmaster at oehoeboeroe dot nl | Date: | Sat, 18 Apr 2009 09:07:54 +0000 |
| Subject: | note 90369 added to function.substr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-153462@lists.php.net to get a copy of this message | ||
You might expect substr('123456', 6) to return an empty string. Instead it returns boolean
FALSE.
This behavior should be mentioned in the Return Values section of the manual. Instead it is only
mentioned in the Parameters section.
If you need an empty string instead of a boolean FALSE you should typecast the result to a string.
$a = substr('123456', 6); // equivalent to $a = FALSE
$a = (string) substr('123456', 6); // equivalent to $a = '';
----
Server IP: 83.137.20.135
Probable Submitter: 82.92.197.212
----
Manual Page -- http://www.php.net/manual/en/function.substr.php
Edit -- https://master.php.net/note/edit/90369
Del: integrated -- https://master.php.net/note/delete/90369/integrated
Del: useless -- https://master.php.net/note/delete/90369/useless
Del: bad code -- https://master.php.net/note/delete/90369/bad+code
Del: spam -- https://master.php.net/note/delete/90369/spam
Del: non-english -- https://master.php.net/note/delete/90369/non-english
Del: in docs -- https://master.php.net/note/delete/90369/in+docs
Del: other reasons-- https://master.php.net/note/delete/90369
Reject -- https://master.php.net/note/reject/90369
Search -- https://master.php.net/manage/user-notes.php