Category: PHP, PHP

Posted on Feb24th2021 by Matthias Noback It doesn't focus on PHP programming, but shows how PHP can be used to serve dynamic web pages.

You can verify that this works by running php -i, which displays all the current PHP settings: This produces a lot of output, but we can use grep to limit it to lines that contain display_errors: This should produce the following output: Now try it again with only the original php.ini: The output of this command is: STDOUT here means that PHP errors will be added to the output of the script, and this means they will show up in the browser.

Now start the PHP server in development mode (with only php.ini): Go to http://localhost:8000/oops and you should see the PHP warning on your screen: On line 3 we try to open a file that doesn't exist and PHP will trigger a PHP error for this.

Now that we convert the PHP error to a RuntimeException our own exception handler will catch it and show a nice error page: This is great because from now on PHP errors and exceptions will be handled in a uniform way: Even though this is great and will work in most situations, PHP errors aren't always easy to catch and handle.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners