Thread: If, else and ==
View Single Post
Old 02-15-2008, 07:26 PM   #10 (permalink)
xenon
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

Quote:
Originally Posted by ReSpawN View Post
Why use a tremendous slow function (if used too much) if you can use if ($var == '') { continue; }.
Because empty doesn't check only if the argument is 0 (zero), it checks for other empty values, as well. This would be the rewriting of the empty function:

php Code:
function custom_empty( $val )
{
    if( $val === '' ||
        $val === 0 ||
        $val === '0' ||
        $val === null ||
        $val === false ||
        $val === array() )
    {
        return true;
    }
   
    return false;
}

So...why is it a so 'tremendous slow function'?
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.

Last edited by Wildhoney : 02-15-2008 at 08:20 PM.
xenon is offline  
Reply With Quote