Edit report at https://bugs.php.net/bug.php?id=63348&edit=1

 ID:                 63348
 Updated by:         s...@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

Reply via email to