note 99439 added to function.substr

From: Date: Tue, 17 Aug 2010 19:38:09 +0000
Subject: note 99439 added to function.substr
Groups: php.notes 
Request: Send a blank email to php-notes+get-171786@lists.php.net to get a copy of this message
I'm not sure if this is just an issue with PHP4, but apparently the substr method will add a carriage control character to the begging of the returned string. This can leave you pulling your hair out over a simple string comparison if you're not aware of it. $result = substr($sql, -13); result = trim($result); if ( $result == "RESOURCES" ) echo "a match!" ---- Server IP: 69.147.83.197 Probable Submitter: 65.120.206.57 ---- Manual Page -- http://www.php.net/manual/en/function.substr.php Edit -- https://master.php.net/note/edit/99439 Del: integrated -- https://master.php.net/note/delete/99439/integrated Del: useless -- https://master.php.net/note/delete/99439/useless Del: bad code -- https://master.php.net/note/delete/99439/bad+code Del: spam -- https://master.php.net/note/delete/99439/spam Del: non-english -- https://master.php.net/note/delete/99439/non-english Del: in docs -- https://master.php.net/note/delete/99439/in+docs Del: other reasons-- https://master.php.net/note/delete/99439 Reject -- https://master.php.net/note/reject/99439 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#171786) next »