我在Vagrant(Ubuntu 16.04,Apache2,PHP7)中设置了一个LAMP堆栈,并且PHP没有显示任何错误。我有以下文件应该返回错误:在php.ini中,即使使用display_errors = On也没有错误
This is a PHP File
<?php thisisnotafunction(); ?>
<?php echo date("ThisIsAnInvalidArgument"); ?>
其他堆栈溢出的职位(post 1,post 2,post 3)的状态,我需要改变php.ini文件中显示错误。
运行$ sudo find/-name php.ini
回报:
/etc/php/7.0/apache2/php.ini
/etc/php/7.0/cgi/php.ini
/etc/php/7.0/cli/php.ini
我走进那些中的每一个,并设置display_errors = On
,重新启动的Apache2,但仍没有任何错误。然而,增加后续到我的index.php文件确实显示错误:
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
require_once("sample.php");
?>
的index.php现在返回:
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
所以很明显我的PHP安装知道如何处理错误。
Apache指令可以设置或取消设置此标志,ini可能不是您安装使用的那个(也不一定要调用php.ini,php7可以读取inis等的目录等) – pvg