ID: 10678
Updated by: torben
Reported By: [EMAIL PROTECTED]
Old-Status: Open
Status: Bogus
Bug Type: *General Issues
PHP Version: 4.0.4pl1
Assigned To: 
Comments:

This has been discussed several times on the mailing lists;
check the archives at http://marc.theaimsgroup.com.

The answer is in the manual: 

http://www.php.net/manual/en/language.operators.comparison.php

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:

$haystack='1230';

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



---------------------------------------------------------------------------



ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at http://bugs.php.net/?id=10678&edit=2


-- 
PHP Development Mailing List <http://www.php.net/>
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