Is it possible to separate try/catch block between separate files? For example, I have a page_start.php which opens the try:
<?php
try {
and then this file is included at the start of various other files. The page_end.php is included at the bottom to close the try:
<?php
} catch(Exception $e) {
// Do something here
}
When I try this I get:
Parse error: syntax error, unexpected $end in page_start.php on line X
Can this be done?
Thanks in advance.
Check the manual out: http://php.net/manual/en/function.include.php
It says this:
The file is evaluated, so therefore it should contain valid PHP, and not end with an open ‘stache. So the answer is no, it cannot be done.