Some days I hate PHP myself

Some days I get why some developers hate on PHP

Checking if a string exists in another string

$string_found = stristr($text, $original_text);
if( $string_found !== FALSE ) {
// do stuff
}

instead of just being able to do

$string_found = stristr($text, $original_text);
if( $string_found ) {
// do stuff
}

because of the fact that stristr returns either an integer, which could be zero (which evaluates as a boolean to FALSE) or a boolean FALSE;

*sigh*


Posted

in

by

Tags:

Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.