note 14068 added to function.trigger-error.php

From: Date: Mon, 16 Jul 2001 04:28:25 +0000
Subject: note 14068 added to function.trigger-error.php
Groups: php.notes 
Request: Send a blank email to php-notes+get-15412@lists.php.net to get a copy of this message
Fatal error: Cannot divide by zero in /home/phpwebmaster/public_html/test2.php on line 11 That almost looks evil, doesn't it? Except that I made PHP print that out. You see, most of use apply echo() style error checking in PHP, when in fact we could be using the trigger_error() function. For example: <?php $divisor =; if (assert ($divisor =0)) trigger_error ("Cannot divide by zero", E_USER_ERROR); ?> That will print out a PHP like error, making it easy to find errors in your logic. It will print out the page, and the line number that the trigger_error() function is called on. A handly little tool in debugging, as well as controlling error messages. It also looks much more prefossional than echo "Cannot divide by zero" Happy coding! Note: This was taken directy from the PHP Newsletter located here: http://www.newbienetwork.net http://www.php.net/manual/en/function.trigger-error.php

« previous php.notes (#15412) next »