if 语句中的 include 语句是否由服务器编译?
我正在尝试减少 index.php
的加载时间。 将我的 if {code}
语句减少为 if {include}
会减少加载时间还是所有包含内容都会被编译?
IE
//old code:
<?php
if (isset($_get("about")){
my_sql code...;
echo about me code...;
?>
//new code:
<?php
if (isset($_get("about")){
include "./include/about.php";
?>
I am attempting to reduce load time on my index.php
.
Will having my if {code}
statements reduced to if {include}
decrease load time or are all includes compiled anyway?
i.e.
//old code:
<?php
if (isset($_get("about")){
my_sql code...;
echo about me code...;
?>
//new code:
<?php
if (isset($_get("about")){
include "./include/about.php";
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仅当
if
条件为true
时才会包含该包含内容。在我看来,这是否真的能加快编译速度是值得怀疑的,因为打开和读取另一个文件可能会抵消通过编译更少的代码而获得的任何速度。仅当代码更易于阅读且更易于维护时,才应将代码分成单独的文件。为了提高速度,请使用操作码缓存。The include will only be included if the
if
condition istrue
. Whether this actually speeds up compilation is questionable IMO, since opening and reading another file will probably pretty much negate any speed gained through having to compile less code. You should only separate your code into separate files if it makes the code easier to read and more maintainable. For speed, use an opcode cache.