I'm currently writing up some classes and functions, and have been using trigger_error() to flag up inappropraire function calls, or the obvious use, errors.
I have a slight niggle with it though, and that is the error number and file name reported by the error.
For example, I have a class in a file "fooBar.php" which is included. One of the methods ('myFunc' in this example) within the class uses trigger_error() to report when the incorrect arguments are supplied, nothing fancy, just:
fooBar.php:
Code: Select all
<?php
class fooBar {
function myFunc ($var1 = false, $var2 = false)
{
if (($var === false) || ($var2 === false)) {
trigger_error('Incorrect arguments specified for method myFunc!', E_USER_NOTICE);
return false;
} else {
//do stuff...
}
}
}
?>somepage.php:
Code: Select all
<?php
include_once 'fooBar.php';
$foo = new fooBar();
$foo->myFunc();
?>Code: Select all
Incorrect arguments specified for method myFunc! on /path/to/fooBar.php on line: 7Code: Select all
Incorrect arguments specified for method myFunc! on /path/to/somepage.php on line: 7