首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >以这种方式编写PHP代码有任何性能优势吗?

以这种方式编写PHP代码有任何性能优势吗?
EN

Stack Overflow用户
提问于 2019-04-01 00:08:41
回答 1查看 0关注 0票数 0

我继承了一些我需要修复PHP 7+的代码; 为了弄清楚失败的原因,我不得不打破以下声明:

代码语言:javascript
复制
$string = str_replace('?>', '', str_replace( array('<?php', '<?'), '', preg_replace_callback( "/\?>((.|\n)*?)<\?(php)?/","eval_mixed_helper",$string) ) );

这个单一(对我来说是错综复杂的)陈述可以细分为:

代码语言:javascript
复制
    // 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);

将所有这些结合到一个陈述中是否有任何表现或其他好处?

EN

回答 1

Stack Overflow用户

发布于 2019-04-01 09:38:41

比另一个更可读。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100006528

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档