douhao6271 2014-04-19 04:33
浏览 71
已采纳

对于HHVM,不推荐使用preg_replace()/ e修饰符

I'm getting error with Symfony 1.4 Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /vagrant/lib/util/sfToolkit.class.php on line 365

The function concerned is below:

public static function pregtr($search, $replacePairs)
  {
    if(strpos(implode(', ', $replacePairs),'e') > 0)
      print_r($replacePairs);

    return preg_replace(array_keys($replacePairs),array_values($replacePairs), $search);
  }

The values concerned is:

Array
(
    [#/(.?)#e] => '::'.strtoupper('\1')
    [/(^|_|-)+(.)/e] => strtoupper('\2')
)

How can I change this to what is equivalent using preg_replace_callback?

  • 写回答

1条回答 默认 最新

  • dongzhuo6137 2014-04-22 12:16
    关注

    You can try to use the sf 1.5. version maintained by guys from L'Express: https://github.com/LExpress/symfony1 (they have fixed the problem)

    If their changes are too much you can check how they managed to solve the 'e modifier' problem and copy their solution. Searching the code for use of pregtr it looks that there are only three places where the e modifier is used (in lib/util/sfInflector.class.php and in filter form classes in the Doctrine and Proper plugins). It's not that difficult to fix the code by yourself in those places.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化