Jump to content

Weird php


dreamwest

Recommended Posts

You're confusing OR (||) with AND (&&)

 

if ($action2 != "off" || $action2 != "on"){

$action2 != "off"    -> True

$action2 != "on"    -> False

OR (||) means if either condition is true, execute the code

so because $action2 != "off" is True, the code is executed.

 

if ($action2 != "off" && $action2 != "on"){

$action2 != "off"    -> True

$action2 != "on"    -> False

AND (&&) means if both conditions are true, execute the code

so because $action2 != "on" is False, the code is not executed.

 

 

Link to comment
https://forums.phpfreaks.com/topic/161047-weird-php/#findComment-849901
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.