ID: 10678
Updated by: torben
Old-Status: Open
Status: Bogus
Bug Type: *General Issues
PHP Version: 4.0.4pl1
Assigned To: 

This has been discussed several times on the mailing lists;
check the archives at

The answer is in the manual:

Basically, 0 is a false value but is of type int. You want
to test for a return value of false (type boolean), so you
need the 'identical' comparison operator: '==='.

$haystack = '1230';
if (strstr($haystack, '0') === false) {
    echo "oh no\n";

Previous Comments:

[2001-05-04 19:21:26] [EMAIL PROTECTED]

There is a subtle problem with functions returning 'false' as
an return status indication.

Take for example strstr(haystack, needle). 

The function returns 'false' to indicate that <needle> could not
be found in <haystack> or returns the substring of haystack
starting with <needle>

With certain strings the above assertion is not true with php:


if (strstr($haystack,"0")==false)
        { echo ' oh no.. '; }


ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at

PHP Development Mailing List <>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to