Maison >développement back-end >tutoriel php >preg_replace_callback出现内存泄露。有人解决了么?该怎么处理
preg_replace_callback出现内存泄露。有人解决了么?
环境:php5.4.22 +centos 5.4+nginx
--------------------------------------------------------------------------------------------------------------
下面这个问题发现的:http://bbs.csdn.net/topics/390784375
----------------------------------
同样问题:
http://bbs.csdn.net/topics/390693060
----------------------------------------------------------------------
测试代码:
<br /><?php<br />$content='<php>asdfsadf</php><php>asdfsadf</php><php>asdfsadf</php><php>asdfsadf</php><php>asdfsadf</php><php>asdfsadf</php> testtest';<br />$a=123;<br />$content= preg_replace_callback('/<php(\s*?)>(.*?)<\/php(\s*?)>/is', function($match) use($a){return 123;}, $content);<br />echo $content;<br />
$content = preg_replace_callback('/[a-z]/', function ( $matches ) {<br /> return strtoupper($matches[0]);<br /> }, 'abdfrew');<br />echo $content;<br />
$content = 'abdfrew';<br />preg_match_all('/[a-z]/', $content, $matches );<br />foreach($matches[0] as $v) $r[$v] = strtoupper($v);<br />$content = strtr($content, $r);<br />echo $content;