Building Custom PHP Error Handling 🌱

  1. Navigate to PHP install directory in Explorer
  2. Edit php.ini in a text editor
  3. Find ;auto_prepend_file
  4. Uncomment the line by removing the ;
  5. Setting the value of auto_prepend_file to the full path of a PHP file will include the file automatically before every .php page the server loads

    auto_prepend_file = "C:\xampp\htdocs\library\global_header.php";

    • There is also an auto_append_file setting to add the include after every .php page the server loads
  6. Save
  7. Navigate to Apache install directory/htdocs in Explorer
  8. Create a library directory
  9. Download Download
  10. Extract the contents of to the library directory


  11. Restart the Apache service
  12. Create a .php page with intentional errors to invoke the new error page
  13. Launch a browser and navigate to the test .php page