note 105208 deleted from function.strpos by danbrown

From: Date: Wed, 03 Aug 2011 13:14:15 +0000
Subject: note 105208 deleted from function.strpos by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-182160@lists.php.net to get a copy of this message
Note Submitter: support at tothepointsolution dot com ---- 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.

« previous php.notes (#182160) next »