发生错误时,php返回页面不显示错误消息

时间:2018-02-12 04:29:44

标签: php apache

我已经安装了Apache2.4和PHP7.2.2

我调试了一些php页面,他们有错误,返回页面显示错误消息

然后我编辑了httpd.conf,更改了行

DocumentRoot "C:\Apache24\htdocs"
<Directory "C:\Apache24\htdocs">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks ExecCGI

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

DocumentRoot "D:\mywebs"
    <Directory "D:\mywebs">

然后当一个页面出错时,它只显示从页面开头到该行的内容有错误但它没有显示错误信息

我已将路径更改回“C:\ Apache24 \ htdocs”,但仍然存在问题

任何人都可以提供帮助

感谢阅读。

1 个答案:

答案 0 :(得分:0)

要显示,您必须配置PHP而不是apache服务器 您可以使用一些php内置函数来显示错误或更改配置文件

使用PHP

您已在PHP文件的根目录中添加以下代码

<?php
  ini_set('display_errors', 1);
  error_reporting(E_ALL);
?>

使用php.ini文件

在PHP安装中找到php.ini文件并打开它,搜索display_errors 变量和设定值On

display_errors=On

然后重启服务器