I'm setting up a LAMP stack in Vagrant (Ubuntu 16.04, Apache2, PHP7) and PHP isn't showing any errors. I have the following file that should return errors:
This is a PHP File
<?php thisisnotafunction(); ?>
<?php echo date("ThisIsAnInvalidArgument"); ?>
Other Stack Overflow posts (post 1, post 2, post 3) state that I need to change the php.ini file to display errors.
Running $ sudo find / -name php.ini
returns:
/etc/php/7.0/apache2/php.ini
/etc/php/7.0/cgi/php.ini
/etc/php/7.0/cli/php.ini
I went into each one of those and set display_errors = On
, restarted apache2, but still no errors. However, adding the follow to my index.php file does show errors:
<?php
error_reporting( E_ALL );
ini_set( "display_errors", 1 );
require_once( "sample.php" );
?>
index.php now returns:
This is a PHP File
Warning: require_once(sample.php): failed to open stream: No such file or directory in /var/www/html/index.php on line 6
Fatal error: require_once(): Failed opening required 'sample.php' (include_path='.:/usr/share/php') in /var/www/html/index.php on line 6
So clearly my PHP setup knows how to deal with errors.