i need capture the last error on function "include" PHP.
I test with the functions "Exceptions", but unfortunately i have written above the function "include".
If I write after the function "include" does not show the exception.
Example 1:
try{
throw new exception();
require_once( $this->controller['path'] );
}
catch( exception $e )
{
print_r( error_get_last() );
}
This Return: ...(Void)...
Example 2:
try{
require_once( $this->controller['path'] ) OR throw new exception();;
}
catch( exception $e )
{
print_r( error_get_last() );
}
This return: Parse error: syntax error, unexpected T_THROW in...
I purposely created a syntax error in the file to include. The idea is to trap the error so that you can debug them.
Anyone have any idea how to get this?
Guys! I need to catch syntax errors. Greetings!
token_get_all()on the individual files. Not sure what happens if there was a parse error though (maybe an empty array)?requiredoes. You just have to bootstrap the app at some point, including all needed dependencies is IMO part of that step. It does not fall into the "needs to be handled gracefully" category yet.