Re: preg_match too greedy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>>>> echo (preg_match($pattern, $test) != false)
>>
>> The " != false " here is redundant.
> 
> Understood. But what you think is redundancy is, to me, clarity in
> programming. I happen to think that boolean tests shouldn't ride on
> whether or not an array returned from a function is empty or not (or a
> freaking boolean). If what I'm looking for is a "false" then that's what
> I'll test for.

Fair enough, but in that case I think you want "!== false". The expression you
have -- "($x != false)" -- will be true whether $x is 0, NULL, an empty string,
an empty array, or actually FALSE.

But "$x !== false" will only be true in the last case.

Ben

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux