Tutorial for Logical operators

What is Logical operators?

They combine conditionals and are mostly used to track several conditions at the same time. For example, the PHP (or) operator verifies that at least one out of every two is correct. If you want to check if they’re both legitimate, you may use the PHP (and) operator. For further information, see the table below:

  • Operator Name Example Result
  • and And $x and $y True if both $x and $y are true
  • or Or $x or $y True if either $x or $y is true
  • xor Xor $x xor $y True if either $x or $y is true, but not both
  • && And $x && $y True if both $x and $y are true
  • || Or $x || $y True if either $x or $y is true
  • ! Not !$x True if $x is not true

Example:-

Output:-

Tagged : / / / / / /