[英]Localhost - PHP Include Not Showing Errors
I've just installed the latest version of Appserv ( 9.3.0 ), which includes:我刚刚安装了最新版本的 Appserv ( 9.3.0 ),其中包括:
Apache 2.4.41
PHP 7.3.10
MySQL 8.0.17
phpMyAdmin 4.9.1
I'm using Localhost as my root directory and trying to reuse old files to build a new website, but I'm noticing a problem.我使用 Localhost 作为我的根目录并尝试重用旧文件来构建一个新网站,但我注意到一个问题。
I'm using the include()
function, but there is a problem.我正在使用
include()
函数,但是有一个问题。
<?php include(file.php); ?>
<?php include(file.php); ?>
shows the contents of file.php
, but, if I delete file.php
, it doesn't give me an error message saying file.php could not be found
. <?php include(file.php); ?>
显示file.php
的内容,但是,如果我删除file.php
,它不会给我一条错误消息说file.php could not be found
。 Why is this?为什么是这样?
Answer to secondly:回答二:
include()
on a non-existent file produces an error of type E_WARNING
. include()
对不存在的文件产生E_WARNING
类型的错误。 For testing purposes simply add this line of code出于测试目的,只需添加这行代码
error_reporting(1);
before using an include()
statement.在使用
include()
语句之前。
For production you should avoid displaying any kind of errors.对于生产,您应该避免显示任何类型的错误。 You can register your own error handler with
set_error_handler()
.您可以使用
set_error_handler()
注册您自己的错误处理程序。
set_error_handler(function ($no, $err, $file, $line)
{
// do whatever you want to if an error of type E_WARNING occurs
}, E_WARNING);
In Windows 10, go to:在 Windows 10 中,转到:
Start > Appserv > PHP Edit php.ini
Find line : display_errors Off
and change to display_errors On
查找行:
display_errors Off
并更改为display_errors On
Save & Close
Start > AppServ > Apache Restart
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.