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*
Leave a Reply