我继承了一些我需要修复PHP 7+的代码; 为了弄清楚失败的原因,我不得不打破以下声明:
$string = str_replace('?>', '', str_replace( array('<?php', '<?'), '', preg_replace_callback( "/\?>((.|\n)*?)<\?(php)?/","eval_mixed_helper",$string) ) );
这个单一(对我来说是错综复杂的)陈述可以细分为:
// first find every chunk of html between a php end tag and the next start tag
// and wrap it with a statement provided by the callback
$string = preg_replace_callback( "/\?>((.|\n)*?)<\?(php)?/","eval_mixed_helper",$string);
// next, remove all php start tags
$string = str_replace(array('<?php', '<?'), '', $string);
// lastly, remove all php end tags
$string = str_replace('?>', '', $string);
将所有这些结合到一个陈述中是否有任何表现或其他好处?
发布于 2019-04-01 09:38:41
比另一个更可读。
https://stackoverflow.com/questions/-100006528
复制相似问题