【问题标题】:Newest PHP and preg_replace()最新的 PHP 和 preg_replace()
【发布时间】:2014-02-28 03:10:55
【问题描述】:

欢迎。

我有问题,因为当我安装最新的 Xampp 时,我的网站出现错误,但我无法使用 PHP,我不知道如何修复它。

错误内容:

不推荐使用:preg_replace():不推荐使用 /e 修饰符,请使用 preg_replace_callback 而不是在 C:\xampp\htdocs\EXTREME\system\bbcodes\mail.php 在第 35 行

Mail.php 内容:

<?php defined('EF5_SYSTEM') || exit;

$_locale->load('mail');

$bbcode_info = array(
    'name' => __('Mail'),
    'description' => __('Displays the text as an e-mail address'),
    'value' => 'mail'
);

if($bbcode_used)
{
    $text = preg_replace('#\[mail=([\r\n]*)([^\s\'\";:\]*?)\](.*?)([\r\n]*)\[/mail\]#sie', "'<a href=\'http://mailto:'.HELP::hide_email('\\2').'\' target=\'_blank\' title=\''.HELP::hide_email('\\2', '\\2').'\'>'.HELP::hide_email('\\2').'</a>'", $text);
    $text = preg_replace('#\[mail\]([\r\n]*)([^\s\'\";:\]*?)([\r\n]*)\[/mail\]#sie', "'<a href=\'http://mailto:'.HELP::hide_email('\\2').'\' target=\'_blank\' title=\''.HELP::hide_email('\\2').'\'>'.HELP::hide_email('\\2').'</a>'", $text);
}

【问题讨论】:

    标签: php preg-replace deprecated preg-replace-callback


    【解决方案1】:

    按照错误消息的建议尝试不使用 e 修饰符

    <?php defined('EF5_SYSTEM') || exit;
    
    $_locale->load('mail');
    
    $bbcode_info = array(
        'name' => __('Mail'),
        'description' => __('Displays the text as an e-mail address'),
        'value' => 'mail'
    );
    
    if($bbcode_used)
    {
        $text = preg_replace('#\[mail=([\r\n]*)([^\s\'\";:\]*?)\](.*?)([\r\n]*)\[/mail\]#si', "'<a href=\'http://mailto:'.HELP::hide_email('\\2').'\' target=\'_blank\' title=\''.HELP::hide_email('\\2', '\\2').'\'>'.HELP::hide_email('\\2').'</a>'", $text);
        $text = preg_replace('#\[mail\]([\r\n]*)([^\s\'\";:\]*?)([\r\n]*)\[/mail\]#si', "'<a href=\'http://mailto:'.HELP::hide_email('\\2').'\' target=\'_blank\' title=\''.HELP::hide_email('\\2').'\'>'.HELP::hide_email('\\2').'</a>'", $text);
    }
    

    我在这两行中都将#sie 更改为#si

    e 修饰符允许您在正则表达式中计算 PHP 代码,但现在它已被弃用,不应再使用。反正你也不需要它。

    【讨论】:

      猜你喜欢
      • 2013-07-17
      • 2015-09-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-19
      • 1970-01-01
      相关资源
      最近更新 更多