Code to create empty files in PHP [file_put_contents vs touch]_PHP tutorial

WBOY
Release: 2016-07-21 15:21:34
Original
993 people have browsed it

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.

www.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...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!