I've never worked with advanced error handling, and I can't find an obvious answer searching.
In the scope a script (require_once
) how do you set up a custom "die" message?
Generally my users see the page-load die with no response. I'd like to direct them to a help file regarding memory so they absolutely cannot miss the solution.
You can kill a script and output a message using the die() command
die("Your message here");
You can also throw custom exceptions in PHP 5+, and catch them and at that point output a message to the users.
require_once
automatically stops execution if it fails.
Try e.g. (include_once file.php) or header('Location: http://.../path/to/help');
, or
if(!(include_once file.php)) {
// redirect?
}