Use short-circuit logical expressions in PHP

Description

The following code shows how to use short-circuit logical expressions.

Example


/* w  ww .j  ava 2  s  . co m*/
<?php
  $numerator = 5;
  $divisor = 0;
  if(($divisor == 0) OR (($num / $divisor) > 1))
  {
    print("The result is greater than 1");
  }
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Language Basic »




PHP Introduction
PHP Operators
PHP Statements
Variable
PHP Function Create
Exception
PHP Class Definition