topical media & game development

talk show tell print

basic-php-09-exception.php / php



  <?php
  //x = "";                //Throws null Exception
  //x = "500";                //Throws less than Exception
  x = "1000";                //Throws NO Exception
  
  try {
    if (x == "") {
      throw new Exception("Variable cannot be null");
    }
    if (x < 1000) {
      throw new Exception("Variable cannot be less than 1000");
    }
    echo "Validation Accepted!";
  }
  catch (Exception exception) {
    echo exception->getMessage();
    echo " - Validation Denied!";
  }
  ?>
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.