Posts Tagged ‘operator’

Which PHP Logical Operator Is Better – ‘and’ or ‘&&’?

Saturday, February 16th, 2008

I was browsing the Sitepoint forum today and somebody raised this question – is it better to use ‘and’ or ‘&&’ as a logical operator in PHP?

In most cases, they evaluate the same way. For example, these two statements are equivalent.

if ($x && $y) { ... }
if ($x and $y) { ... }

So what’s the difference?
(more…)