note 74870 added to function.substr

From: Date: Tue, 01 May 2007 17:51:48 +0000
Subject: note 74870 added to function.substr
Groups: php.notes 
Request: Send a blank email to php-notes+get-126097@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 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) ---- Server IP: 69.39.81.135 Probable Submitter: 151.75.161.141 ---- Manual Page -- http://www.php.net/manual/en/function.substr.php Edit -- https://master.php.net/note/edit/74870 Del: integrated -- https://master.php.net/note/delete/74870/integrated Del: useless -- https://master.php.net/note/delete/74870/useless Del: bad code -- https://master.php.net/note/delete/74870/bad+code Del: spam -- https://master.php.net/note/delete/74870/spam Del: non-english -- https://master.php.net/note/delete/74870/non-english Del: in docs -- https://master.php.net/note/delete/74870/in+docs Del: other reasons-- https://master.php.net/note/delete/74870 Reject -- https://master.php.net/note/reject/74870 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#126097) next »