首页 >后端开发 >php教程 >preg_replace(): The /e modifier is deprecated, use preg_replace_callback

preg_replace(): The /e modifier is deprecated, use preg_replace_callback

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB原创
2016-06-06 20:43:001058浏览

以前项目里有个函数:

<code>preg_replace("/([A-Z])/e", "'_' . strtolower('\\1')", $str)
</code>

升级完php之后,就一直报:

<code>preg_replace(): The /e modifier is deprecated, use preg_replace_callback 
</code>

请问这个要怎么改?

回复内容:

以前项目里有个函数:

<code>preg_replace("/([A-Z])/e", "'_' . strtolower('\\1')", $str)
</code>

升级完php之后,就一直报:

<code>preg_replace(): The /e modifier is deprecated, use preg_replace_callback 
</code>

请问这个要怎么改?

<code class="lang-php">preg_replace_callback('/([A-Z])/',
                      function ($matches) {
                        return '_' . strtolower($matches[0]);
                      },
                      $str)
</code>

提问前就没有想过看看文档吗?

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn