Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Logical operators #13

#1

Hi,

I have questions. Why should I use "AND" insted "&&" ? What's difrent? In all language I use "&&" and I never have problems with it. That's rly odd for me now. What's happen when I use "&&" in code? I think nothing happen when I have simple if (a > 0 && b > 0)...

Greetings,
Zdanc32

  • solved #2
  • replies 2
  • views 2.4K
  • likes 0
#2

Hi,

we recently switch to && so you shouldn't use AND you should use &&, our guide isn't updated.
I will take care of that and inform you as soon as this is updated.

If your want to now the difference and why we switched form AND|OR to && || here is a example why AND is considered bad practice:

$x = false || true;  // is ($x = (false || true)) => true
$x = false or true;  // is (($x = false) or true) => false
    
$x = true && false;  // is ($x = (true && false)) => false
$x = true and false; // is (($x = true) and false) => true

Thanks for your patience and thanks for noticing.

Zdanc32 accepted post #2 as the answer
#3