Home > Backend Development > PHP Tutorial > preg_replace(): The /e modifier is deprecated, use preg_replace_callback

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

WBOY
Release: 2016-06-06 20:43:00
Original
1027 people have browsed it

以前项目里有个函数:

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

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

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

请问这个要怎么改?

回复内容:

以前项目里有个函数:

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

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

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

请问这个要怎么改?

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

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

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template