note 105208 added to function.strpos

From: Date: Wed, 03 Aug 2011 01:22:25 +0000
Subject: note 105208 added to function.strpos
Groups: php.notes 
Request: Send a blank email to php-notes+get-182126@lists.php.net to get a copy of this message
Just a quick note to help you if you stumble upon this strange issue. Basically, if the string starts with "-", strpos is not detecting it for some reason maybe it is a bug or I am missing something. Anyways, here is for to know the issue and not waste time. Example: <?php // example 1 $arg = 'something-i'; var_dump(strpos($arg, '-')); // will return the correct value (int(11)) // example 2 WRONG $arg = '-i'; var_dump(strpos($arg, '-'));// will return false and should return int(1); // example 3 - here we escape the value $arg = '-i'; var_dump(strpos('\\'.$arg, '-')); // will return the correct value (int(1)) ?> In example 1 all goes normal. As you can see in the second example, you should get an integer value instead, you get false which is not right. If the value is escaped as in example 3, there are no problems it returns the proper value. ---- Server IP: 69.147.83.197 Probable Submitter: 178.249.174.201 ---- Manual Page -- http://www.php.net/manual/en/function.strpos.php Edit -- https://master.php.net/note/edit/105208 Del: integrated -- https://master.php.net/note/delete/105208/integrated Del: useless -- https://master.php.net/note/delete/105208/useless Del: bad code -- https://master.php.net/note/delete/105208/bad+code Del: spam -- https://master.php.net/note/delete/105208/spam Del: non-english -- https://master.php.net/note/delete/105208/non-english Del: in docs -- https://master.php.net/note/delete/105208/in+docs Del: other reasons-- https://master.php.net/note/delete/105208 Reject -- https://master.php.net/note/reject/105208 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#182126) next »