I have code like this
try {
header("Location: http://www.google.com\n-abc");
}
catch (Exception $e) {
error_log(print_r($_POST, true));
error_log(print_r($_GET, true));
error_log(print_r($_SERVER, true));
}
Without the try {} catch {} block, I can see the POST, GET and SERVER variables in my error_log, but with the try {} catch {} block, I only see the default PHP error.
- Is there a way to show the POST, GET, and SERVER variables in a try {} catch {} block?
- Is there a way to have PHP include POST, GET, and SERVER variables for ALL errors that get logged to file and not just wherever I have added error_log(print_r($_POST, true)); ….?
But default PHP functions like
headerwill not throw exceptions.If you want them to throw exceptions you will need to set the error handler to use ErrorException: