【问题标题】:How can I display PHP errors through htaccess [duplicate]如何通过 htaccess 显示 PHP 错误 [重复]
【发布时间】:2013-10-30 13:45:14
【问题描述】:

好的,我在一个不允许触摸 php.ini 文件的地方工作,因为服务器服务于许多网站……但是,我被告知我可以通过 htaccess 显示 php 错误,以便我可以调试我的代码,因为现在,我的 PHP 屏幕是空白的,它没有帮助.. 如何通过我的本地 htaccess 文件显示 php 错误而无需访问 php.ini?

【问题讨论】:

    标签: php .htaccess php-ini


    【解决方案1】:

    你应该使用:

    php_flag display_errors on

    在您的 .htaccess 文件中

    【讨论】:

    【解决方案2】:

    您可以使用这些命令启用错误报告并使用您的 .htaccess 文件设置错误级别。

    php_flag display_errors on
    php_value error_reporting <error level>
    

    您还可以使用 error_reporting() 在某种 php 配置文件中定义错误报告。

    error_reporting(E_ALL);
    

    【讨论】:

      【解决方案3】:

      php_flag display_startup_errors on php_flag display_errors on php_flag html_errors on

      启用 PHP 错误记录

      php_flag log_errors on php_value error_log /httpdocs/域名/PHP_errors.log

      使用 htaccess,您可以指定 PHP 错误的最大大小。这控制每个记录错误的大小,而不是整体文件大小。这是一般语法:

      设置最大错误大小的通用指令

      log_errors_max_len 整数

      参考链接:http://perishablepress.com/advanced-php-error-handling-via-htaccess/

      【讨论】:

        猜你喜欢
        • 2011-09-01
        • 2014-11-10
        • 2014-03-17
        • 1970-01-01
        • 2011-12-01
        • 1970-01-01
        • 1970-01-01
        • 2020-06-05
        • 1970-01-01
        相关资源
        最近更新 更多