I has passed a small test to check which function is faster to create a new file.
file_put_contents vs touch
Copy code The code is as follows:
for($i = ; $i < 100; $i++)
{
file_put_contents('dir/file'.$i, ' ');
}
?>
Average time: 0,1145s
Copy code The code is as follows :
for($i = ; $i < 100; $i++)
{
touch('dir/file'.$i) ;
}
?>
Average time: 0,2322s
So, file_put_contents is faster than touch, about twice.
http://www.bkjia.com/PHPjc/324907.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/324907.htmlTechArticleI has passed a small test to check which function is faster to create a new file. file_put_contents vs touch Copy code code As follows: ?php for($i = ; $i 100; $i++) { file_put_cont...