ID: 10678
User Update by: [EMAIL PROTECTED]
Status: Bogus
Bug Type: *General Issues
Description: distinction between false and "0" (string)

ah .. sorry. thanks for the explanation.


Previous Comments:
---------------------------------------------------------------------------

[2001-05-04 19:34:48] [EMAIL PROTECTED]
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 non";
}


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

[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.. '; }



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


Full Bug description available at: http://bugs.php.net/?id=10678


-- 
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