Home > Backend Development > PHP Tutorial > preg_replace转成preg_replace_callback

preg_replace转成preg_replace_callback

WBOY
Release: 2016-06-13 12:05:45
Original
968 people have browsed it

【求助】preg_replace转成preg_replace_callback
如何把下面代码中的preg_replace用preg_replace_callback代替?

$out = "<?php \n" . '$k = ' . preg_replace("/(\'\\$[^,]+)/e" , "stripslashes(trim('\\1','\''));", var_export($t, true)) . ";\n";
Copy after login


这是ECShop里的代码,安装在php 5.5.x版本上时,会出现这类问题。
------解决方案--------------------
preg_replace_callback("/(\\'\$[^,]+)/" , function($r){return stripslashes(trim($r[1],'\''));}, var_export($t, true))

Related labels:
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