PHP中创建空文件的代码[file_put_contents vs touch]_PHP

WBOY
Release: 2016-06-01 12:13:40
Original
963 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_contents比touch快,大约两倍。

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!