Split TRY and CATCH EXCEPTION across different .php include files -
is there way in php split try , catch across 2 different "include files", putting try in 1 file , catch in another?
something like:
<?php include('begin_try.php'); ... //some code goes here ... include('end_try_and_catch_exceptions.php'); ?> //filename: begin_try.php:
<?php header('content-type: application/json'); seek { ?> //filename: end_try_and_catch_exceptions.php:
<?php } grab (exception $e) { echo json_encode(array( 'error' => array( 'code' => $e->getcode(), 'message' => $e->getmessage() ) )); } ?>
it's not syntactically possible utilize try-catch that, can utilize set_exception_handler function register function grab exceptions not otherwise caught:
set_exception_handler(function ($e) { echo json_encode(array( 'error' => array( 'code' => $e->getcode(), 'message' => $e->getmessage() ) )); }); php try-catch
No comments:
Post a Comment