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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:43:00
Original
1072 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

请问这个要怎么改?

preg_replace_callback('/([A-Z])/',
                      function ($matches) {
                        return '_' . strtolower($matches[0]);
                      },
                      $str)
Copy after login

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

Related labels:
php
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template