Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用include()的性能_Php_Performance - Fatal编程技术网

Php 使用include()的性能

Php 使用include()的性能,php,performance,Php,Performance,在我的项目中,为了有一个更坚实的结构,我通常将代码分成很多文件。以下两个示例在性能上是否存在一些差异 # Sample 1 include('first.class.php'); # class first {} include('second.class.php'); # class second {} # Sample 2 class first {} class second {} 以下两个示例在性能上是否存在一些差异 # Sample 1 include('first.class.p

在我的项目中,为了有一个更坚实的结构,我通常将代码分成很多文件。以下两个示例在性能上是否存在一些差异

# Sample 1
include('first.class.php'); # class first {}
include('second.class.php'); # class second {}

# Sample 2
class first {}
class second {}
以下两个示例在性能上是否存在一些差异

# Sample 1
include('first.class.php'); # class first {}
include('second.class.php'); # class second {}

# Sample 2
class first {}
class second {}
只要不在每个请求中加载成百上千的include,您展示的方法是可以接受的

如果要使用PHP的机制,这也是必需的结构。

有关require/include性能分析的结果,请参阅$搜索引擎也会给出很多结果