So I was reading Twitter a bit until I saw this tweet by @DivineOmega:
The perfect PHP error handler (pretty much), I coded it and I wanted to use it server-wide, but How can I apply this file to all my PHP scripts?
You can use phps auto_prepend_file
and auto_append_file
directives.
It works like loading every script on your server via require_once()
right between the files specified by auto_prepend_file
(Loaded before your script) and auto_append_file
(Loaded right after your script).
To activate in .htaccess
:
php_value auto_prepend_file "/path/to/file/before.php"
php_value auto_append_file "/path/to/file/after.php"
Or in php.ini
(required when running in cgi-mode, affects wole webserver):
auto_prepend_file = "/path/to/file/before.php"
auto_append_file = "/path/to/file/after.php"
before.php
try {
after.php
} catch(Exception $e) {
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With