如何在 .htaccess 中输入多个 PHP 值?

发布于 2024-08-22 08:10:33 字数 320 浏览 2 评论 0原文

我正在编辑 .htaccess 文件,以便对我的 php.ini 文件进行一些覆盖(我无权访问它)。到目前为止,我已经添加:

php_value max_execution_time 600
php_value error_reporting E_WARNING
php_value log_errors Off

我正在编辑的应用程序(vTiger CRM)建议将“error_reporting”设置为“E_WARNING & ~E_NOTICE”。当我输入该值时,我最终得到错误 500。如何添加正确的 error_reporting 值?谢谢。

I'm editing the .htaccess file in order to make some overwrites to my php.ini file (I don't have access to it). So far, I've added:

php_value max_execution_time 600
php_value error_reporting E_WARNING
php_value log_errors Off

The application I'm editing for (vTiger CRM) recommends that "error_reporting" is set to "E_WARNING & ~E_NOTICE". When I put in that value I end up with a Error 500. How can I add the proper error_reporting values? Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

成熟稳重的好男人 2024-08-29 08:10:33

使用诸如 E_WARNING 之类的常量在 PHP 之外没有任何意义 - 当您编写 .htaccess 文件时,您就处于“PHP 之外”。 (请参阅error_reporting,例如)

因此,您不能使用这些常量,而必须使用它们的整数值,您可以在这里找到它们:预定义常量

在您的具体情况下,了解应该使用哪个值的最简单方法是使用一个小型 PHP 脚本来进行计算。

例如:

<?php
var_dump(E_ALL & ~E_NOTICE);

将输出:

int 30711

(比遍历常量值并自己计算要容易得多,我想^^)

Using constants such as E_WARNING has no meaning outside of PHP -- and when you're writting a .htaccess file, you are "outside of PHP". (see the documentation of error_reporting, for instance)

So, you cannot use those constants, and have to use their integer values, which you can find here : Predefined Constants

The easiest way to know which value you should use, in your specific case, is to use a small PHP script to do the calculation.

For instance :

<?php
var_dump(E_ALL & ~E_NOTICE);

Will output :

int 30711

(Much easiser than going through the constants' values, and calculating yourself I suppose ^^ )

鱼忆七猫命九 2024-08-29 08:10:33

您不能在 .htaccess 中使用 php 常量。它们在那种环境中不可用。您应该使用常量代表的整数值。

You can't use the php constants in .htaccess. They're not available in that environment. You should use the integer values that the constants represent.

谎言 2024-08-29 08:10:33

其他需要考虑的事情是在 php 脚本中使用 ini_set() ,其中您将可以访问 php 常量。

ini_set('max_execution_time', '600');
ini_set('error_reporting', E_WARNING);
ini_set('log_errors', '0');

phpsite ini.list.php 上有一个页面,它将向您显示哪些 ini 指令可以通过这种方式设置,以及哪些必须在 php.ini 中设置。 (抱歉,我不能发布多个链接)您给出的 3 个示例都是合法的,可以通过这种方式进行更改。

Something else to consider is using ini_set() in your php script where you will have access to php constants.

ini_set('max_execution_time', '600');
ini_set('error_reporting', E_WARNING);
ini_set('log_errors', '0');

There is a page on the phpsite ini.list.php that will show you which ini directives can be set this way, and which have to be set in php.ini. (I can't post more than one link, sorry) The 3 examples you've given are all legal to change in this way.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文