note 74870 rejected from function.substr by tularis

From: Date: Tue, 01 May 2007 22:07:50 +0000
Subject: note 74870 rejected from function.substr by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-126101@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 4, which is the end of the string $sub = substr('four', 4); // 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 much lazy to do it)

« previous php.notes (#126101) next »