Code has been added to clipboard!

Terminating PHP Script

Example
<?php
  //error handler function
  function custom_error($err_no, $err_str) {
    echo "<b>Error caught!</b> [$err_no] $err_str<br>";
    echo "Script end";
    die();
  }

  //set error handler
  set_error_handler('custom_error', E_USER_WARNING);

  //trigger error
  $test = 3;
  if ($test >= 1) {
    trigger_error('Value has to be 1 or lower', E_USER_WARNING);
  }
?>