basic-php-09-snippet05.php / php
<?php //create your error handler function function handler(error_message, error_line) { switch (//fatal error case E_ERROR: echo "<h1>Fatal Error</h1>"; die("A fatal error has occured at line error_line of file " . "<br>" . "Error message created was "error_message""); break; //warnings case E_WARNING: echo "<h1>Warning</h1>"; echo "A warning has occured at line error_file.<br>"; echo " Error message created was "//notices case E_NOTICE: //don't show notice errors break; } } //set the error handler to be used set_error_handler("handler"); //set string with "Wrox" spelled wrong string_variable = "Worx books are great!"; //try to use str_replace to replace Worx with Wrox //this will generate an E_WARNING //because of wrong parameter count str_replace("Worx", "Wrox"); ?>
(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.