On this page of the PHP docs, the first comment suggests a solution to custom error handling.
Johan writes:
Custom error handling on entire pages can avoid half rendered pages for the users:
<?php
ob_start();
try {
/*contains all page logic
and throws error if needed*/
...
} catch (Exception $e) {
ob_end_clean();
displayErrorPage($e->getMessage());
}
?>
I was already going to use output buffering to avoid the half-render issue, but I hadn't thought of the possibility of surrounding the page render region in a big try/catch block.
In fact coming from a Java world, this kind of practice is more or less considered bad. But I know PHP and Java differ greatly so I'll ask here...
Is the practice above bad in any way (and obviously WHY is it bad)? Thanks!