PHP中创建空文件的代码[file_put_contents vs touch]_php技巧

WBOY
Release: 2016-05-17 09:13:13
Original
981 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

复制代码 代码如下:

for($i = ; $i {
file_put_contents('dir/file'.$i, '');
}
?>

Average time: 0,1145s
复制代码 代码如下:

for($i = ; $i {
touch('dir/file'.$i);
}
?>

Average time: 0,2322s

所以,file_put_contentstouch快,大约两倍。
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!