error reporting on specific folders

喜你入骨 提交于 2019-12-02 00:39:36
Greg

You can use a .htaccess file in Apache. Just add this line:

php_value error_reporting 6143

Or for old PHP versions:

php_value error_reporting 2047

Note that you can't use the contants (like E_ALL)

From the manual:

Note: PHP Constants outside of PHP

Using PHP Constants outside of PHP, like in httpd.conf, will have no useful meaning so in such cases the integer values are required. And since error levels will be added over time, the maximum value (for E_ALL) will likely change. So in place of E_ALL consider using a larger value to cover all bit fields from now and well into the future, a numeric value like 2147483647.

Use an .htaccess file to set the option.

<IfModule mod_php5.c>
  display_errors 1
</IfModule>

Now, naturally this only works if you are using apache as a module.

If you want to add the configuration option when using CGI, your options going to be limited.

A couple of ideas:

  • Including something in every script.
  • More exotic: Use a rewrite rule which pointed to a known script in the directory which did the usual set_ini style argument, and then included the intended script by checking the path. I'm bad with rewrite rules, but I know this could be done.

Just a quick note: putting PHP instructions into .htaccess works only if PHP is installed as an Apache module. With PHP installed as CGI all you get is a 500 Internal server error.

for CGI mode you must use php.ini to accomplish that

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!