去年就曾经测试过php filesystem相关函数和include require的性能,今天无意间看到国外一个更全面的对比,显然include和require是最慢的。所以尽量少用include,尤其是作为缓存,最好还是用文本缓存,我原以为直接缓存为php脚本速度比较快,后来测试才发现include效率很低。 出处:
http://www./wiki/Readfile_vs_include
Function |
Brief Description |
string file_get_contents ( string filename [, int use_include_path]) |
Reads entire file into a string |
int fpassthru ( resource handle) |
Output all remaining data on a file pointer |
string fgets ( resource handle [, int length]) |
Gets line from file pointer |
array file ( string filename [, int use_include_path]) |
Reads entire file into an array |
require(string filename)
include(string filename)
require_once(string filename)
include_once(string filename)
|
includes and evaluates the specific file. |
int readfile ( string filename [, int use_include_path]) |
Outputs a file |