laserlight wrote:What do you mean by "keep its value outside of the function"?
With this:
set_error_handler("errors");
function errors($errno, $errstr, $errfile, $errline, $errcontext) {
global $date;
switch ($errno) {
case E_ERROR:
$errtype = "Fatal Error";
continue;
blah blah blah
}
$errormessage = 'yadayadayada';
print("$errormessage");
}
print("$errormessage"); will print yadayadayada
But I want to be able to do this:
set_error_handler("errors");
function errors($errno, $errstr, $errfile, $errline, $errcontext) {
global $date;
switch ($errno) {
case E_ERROR:
$errtype = "Fatal Error";
continue;
blah blah blah
}
$errormessage = 'yadayadayada';
}
print("$errormessage"); // <-- Outside function
With print("$errormessage"); after the closing bracket of the function and still have it print yadayadayada.
Did that answer your question?