note 74255 deleted from function.substr by nlopess
| From: | nlopess@php.net | Date: | Tue, 01 May 2007 13:44:17 +0000 |
| Subject: | note 74255 deleted from function.substr by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-126055@lists.php.net to get a copy of this message | ||
Note Submitter: legolas558 d0t users dot sf dot net
----
substr() does not behave like other languages' likewise functions, I will explain:
<?php
// extract the substring from offset 3, which is the end of the string
$sub = substr('four', 3);
// dumps (bool) false
var_dump($sub);
?>
The result will be (bool) false while an empty (string) "" was expected, so you will
always have to check for that case or use (string)$sub (I would file a bug for this consistency
issue but I am too lazy to do it)