note 74255 added to function.substr

From: Date: Sun, 01 Apr 2007 11:08:07 +0000
Subject: note 74255 added to function.substr
Groups: php.notes 
Request: Send a blank email to php-notes+get-125004@lists.php.net to get a copy of this message
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) ---- Server IP: 62.73.196.231 Probable Submitter: 151.44.35.227 ---- Manual Page -- http://www.php.net/manual/en/function.substr.php Edit -- https://master.php.net/note/edit/74255 Del: integrated -- https://master.php.net/note/delete/74255/integrated Del: useless -- https://master.php.net/note/delete/74255/useless Del: bad code -- https://master.php.net/note/delete/74255/bad+code Del: spam -- https://master.php.net/note/delete/74255/spam Del: non-english -- https://master.php.net/note/delete/74255/non-english Del: in docs -- https://master.php.net/note/delete/74255/in+docs Del: other reasons-- https://master.php.net/note/delete/74255 Reject -- https://master.php.net/note/reject/74255 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#125004) next »