关注微信公众号:wwwcoder,现在已将博客搬到这里,内容精选过后才发布出来。谢谢大家支持
直接上代码(ss.txt文件大小:9KB):
$filePath = "E:\ss.txt";
$start = microtime(true);
for($i=0;$i<100000;$i++){
$fileContent = file_get_contents($filePath);
}
echo "耗时:".(microtime(true) - $start);
//耗时:8.7904160022736
$filePath = "E:\ss.txt";
$start = microtime(true);
for($i=0;$i<100000;$i++){
$fileHander = fopen($filePath, 'r');
$fileContent = fread($fileHander, filesize($filePath));
}
echo "耗时:".(microtime(true) - $start);
//耗时:7.8777868747711