php 如何解决在Drupal 6.13中使用PHP 5.3.0的deprecated function ereg()
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1132912/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to solve the use of deprecated function ereg() of PHP 5.3.0 in Drupal 6.13
提问by Jo?o Guilherme
Anyone knows how to solve the error below?
有谁知道如何解决下面的错误?
Deprecated: Function ereg() is deprecated in C:\wamp\www\includes\file.inc on line 895
已弃用:函数 ereg() 在 C:\wamp\www\includes\file.inc 中的第 895 行已弃用
It is happening after installing Drupal 6.13 on wamp server 2.0i with PHP 5.3.0
在使用 PHP 5.3.0 在 wamp server 2.0i 上安装 Drupal 6.13 后发生这种情况
回答by Parmendra Singh
Use
用
preg_match('/\.([^\.]*$)/', $this->file_src_name, $extension);
Instead of
代替
ereg('\.([^\.]*$)', $this->file_src_name, $extension);
回答by Alan Storm
Drop your error reporting level below E_DEPRECATED.
将错误报告级别降低到 E_DEPRECATED 以下。
PHP 5.3 introduced two new error reporting levels, E_DEPRECATED and E_USER_DEPRECATED and - for the first time in PHP's history - they've started to walk away from older parts of their API. The ereg_* function will still work, but this warning is intended to let you know that "hey, these function will be going away soon, probably in the next major revision).
PHP 5.3 引入了两个新的错误报告级别,E_DEPRECATED 和 E_USER_DEPRECATED,并且 - 在 PHP 的历史上第一次 - 他们已经开始放弃其 API 的旧部分。ereg_* 函数仍然有效,但此警告旨在让您知道“嘿,这些函数将很快消失,可能在下一个主要修订版中)。
回答by ex_plo_rer
Just add @in front of the function. e.g.
只需在函数前添加@。例如
@ereg()
@ereg()
more issue relating upgraded your web servers which running PHP 5.3.0, pls refer
更多有关升级运行 PHP 5.3.0 的 Web 服务器的问题,请参阅
http://www.rain-forest-forum.com/dotproject-net-installation-issues-t263.html
http://www.rain-forest-forum.com/dotproject-net-installation-issues-t263.html
回答by Ipsita Rout
This is not a Drupal issue.In the Drupal site it is noted that it does not yet support PHP 5.3 and there have been new error flags added to PHP.
这不是 Drupal 问题。在 Drupal 站点中,注意到它尚不支持 PHP 5.3,并且向 PHP 添加了新的错误标志。
Solution1 : You can degarde the PHP version.You can revert back to PHP 5.2.x. As I am unsure of other conflicts with Drupal and PHP 5.3.
解决方案1:您可以降低PHP版本。您可以恢复到PHP 5.2.x。因为我不确定与 Drupal 和 PHP 5.3 的其他冲突。
Solution2 : However, if you prefer to keep PHP 5.3, you can always suppress the deprecated function errors. In Drupal's includes/common.inc, Find the line :
解决方案 2:但是,如果您更喜欢保留 PHP 5.3,您可以随时抑制已弃用的函数错误。在 Drupal 的 includes/common.inc 中,找到以下行:
if ($errno & (E_ALL ^ E_NOTICE)) { And replace it with:
if ($errno & (E_ALL ^ E_NOTICE)) { 并将其替换为:
if ($errno & (E_ALL & ~E_NOTICE & ~E_DEPRECATED)) {
如果 ($errno & (E_ALL & ~E_NOTICE & ~E_DEPRECATED)) {
This will now always suppress the Deprecated error messages.
现在这将始终抑制已弃用的错误消息。
回答by Ipsita Rout
You can edit you common.inc file to quietly disregard the deprecated error flags. See my post: http://funkinetics.org/klink/function-ereg-is-deprecated-error-in-drupal-6x-with-php-53/
您可以编辑您的 common.inc 文件以悄悄地忽略已弃用的错误标志。看我的帖子: http://funkinetics.org/klink/function-ereg-is-deprecated-error-in-drupal-6x-with-php-53/
回答by Simon B.
One solution is to upgrade the offending sourcecode :-) It's explained here: http://drupal.org/node/514334#comment-2852940
一种解决方案是升级有问题的源代码:-) 在这里解释:http: //drupal.org/node/514334#comment-2852940
回答by trante
Because I don't have time to update legacy code, I addeded following line to php code to suppress warnings.
因为我没有时间更新遗留代码,所以我在 php 代码中添加了以下行以抑制警告。
error_reporting(E_ALL ^ E_DEPRECATED);
this line suppress only deprecated warnings. other errors are shown as usual.
此行仅抑制已弃用的警告。其他错误照常显示。
回答by quickcel
Looks like the problem is with PHP 5.3.0. You could try downgrading to 5.2.9 as suggested by this drupal link: http://drupal.org/node/514334
看起来问题出在 PHP 5.3.0 上。您可以尝试按照此 drupal 链接的建议降级到 5.2.9:http: //drupal.org/node/514334

