Symfony 1.4 不推荐使用的 php 函数 [英] Symfony 1.4 deprecated function in php

查看:26
本文介绍了Symfony 1.4 不推荐使用的 php 函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道这是什么错误吗?我需要有关此 Deprecated: preg_replace(): 的帮助:不推荐使用/e 修饰符,请在 C:\xampp\htdocs\sfprojects\jobeet\lib\vendor\symfony\lib\response\sfWebResponse.class 中使用 preg_replace_callback.php 在第 409 行.我正在使用 xampp 1.8.3symfony 1.4.由于这是一周的时间,我无法向前迈进:'(.任何帮助将不胜感激.谢谢.

Anyone know what is this error? I need help with this Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in C:\xampp\htdocs\sfprojects\jobeet\lib\vendor\symfony\lib\response\sfWebResponse.class.php on line 409. I'm using xampp 1.8.3 and symfony 1.4. I couldn't get to step forward because of this a weeke a go :'(. Any help will be appreciated. Thank you.

推荐答案

在 myproject/lib/vendor/symfony/lib/response/sfWebResponse.class.php on line 409

In myproject/lib/vendor/symfony/lib/response/sfWebResponse.class.php on line 409

  protected function normalizeHeaderName($name)
  {
    // return preg_replace('/\-(.)/e', "'-'.strtoupper('\\1')", strtr(ucfirst(strtolower($name)), '_', '-'));    

    return preg_replace_callback(
                  '/\-(.)/', 
                  function ($matches) {
                    return '-'.strtoupper($matches[1]);
                  }, 
                  strtr(ucfirst(strtolower($name)), '_', '-')
        );
  }

修复第 360 行/lib/vendor/symfony/lib/util/sfToolkit.class.php 中的 pregtr 方法

FIX for pregtr method in /lib/vendor/symfony/lib/util/sfToolkit.class.php on line 360

public static function pregtr($search, $replacePairs){
  // return preg_replace(array_keys($replacePairs), array_values($replacePairs), $search);
  foreach($replacePairs as $pattern => $replacement)
  {
    if (preg_match('/(.*)e$/', $pattern, $matches))
    {
      $pattern = $matches[1];
      $search = preg_replace_callback($pattern, function ($matches) use ($replacement) {
        preg_match("/('::'\.)?([a-z]*)\('\\\\([0-9]{1})'\)/", $replacement, $match);
        return ($match[1]==''?'':'::').call_user_func($match[2], $matches[$match[3]]);
      }, $search);
    }
    else
    {
      $search = preg_replace($pattern, $replacement, $search);
    }
  }
  return $search;
}

我结合了重复线程中的两个答案Symfony 1.4 using deprecated functions in php 5.5mikaxtech(请给他们投票)

I've combined two answers from duplicate thread Symfony 1.4 using deprecated functions in php 5.5 answered by mika and xtech (up-vote them please)

它也会影响第 281 行的/lib/form/addon/sfFormObject.class.php

It also affects /lib/form/addon/sfFormObject.class.php on line 281

  protected function camelize($text)
  {
    //return preg_replace(array('#/(.?)#e', '/(^|_|-)+(.)/e'), array("'::'.strtoupper('\\1')", "strtoupper('\\2')"), $text); //ORIGINAL
    return strtr(ucwords(strtr($text, array('/' => ':: ', '_' => ' ', '-' => ' '))), array(' ' => ''));
  }

这篇关于Symfony 1.4 不推荐使用的 php 函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆