strange, my php scripts when execute, if there is any syntax error, i have to open and see the error_log in server’s script folder. The screen shows only
This page isn’t working
example.com is currently unable to handle this request.
HTTP ERROR 500
The above is shown for the following error loged in error_log,
[12-Dec-2018 17:27:39 UTC] PHP Parse error: syntax error, unexpected ‘}’, expecting ‘,’ or ‘;’ in /home/accessto/public_html/demo3/admin/content/dashboard/pages/client_admin/photo_manager/add_pkg_photo.php on line 86
As we are now running PHP7, answers given here are not correct anymore.
The only one still OK is the one from Frank Forte, as he talks about PHP7.
On the other side, rather than trying to catch error with a try/catch you can use a trick:
use include.
Here 3 pieces of code:
<?php
error_reporting(E_ALL);
ini_set('display_errors','On');
include ("tst3.php");
?>
File: tst3.php
<?php
// Missing " and ;
echo "Testing
?>
Now run tst2 which set the error reporting then include tst3. You will see:
Parse error: syntax error, unexpected end of file, expecting variable (T_VARIABLE) or ${ (T_DOLLAR_OPEN_CURLY_BRACES) or {$ (T_CURLY_OPEN) in tst3.php on line 4