Bug #63348 [Opn->Nab]: Unexpected behaviour with strpos()
| From: | sixd@php.net | Date: | Wed, 24 Oct 2012 23:15:20 +0000 |
| Subject: | Bug #63348 [Opn->Nab]: Unexpected behaviour with strpos() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-174273@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=63348&edit=1
ID: 63348
Updated by: sixd@php.net
Reported by: aleksey dot v dot korzun at gmail dot com
Summary: Unexpected behaviour with strpos()
-Status: Open
+Status: Not a bug
Type: Bug
Package: *Programming Data Structures
Operating System: *Nix
PHP Version: 5.3.18
Block user comment: N
Private report: N
New Comment:
The code actually gives this message first:
PHP Warning: strpos() expects parameter 1 to be string, array given
It's standard for PHP to behave like this for parameter parsing errors. E.g. all
but a few of the str* functions are implemented using 'return' in this case. Only
strrpos, strripos, strpbrk, (and substr_compare) use RETURN_FALSE.
Previous Comments:
------------------------------------------------------------------------
[2012-10-24 19:09:02] aleksey dot v dot korzun at gmail dot com
Description:
------------
Please review code snippet below, expected behaviour is that code within if
statement will not be executed (since the value was not found).
Test script:
---------------
<?php
$foobar = array();
if(strpos($foobar, 'something') !== false) {
echo 'fail';
}
?>
Expected result:
----------------
It should not output 'fail'
Actual result:
--------------
Outputs fail
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=63348&edit=1