PHP中创建空文件的代码[file_put_contents vs touch]
作者:bea
I has passed a small test to check which function is faster to create a new file. file_put_contents vs touch 代码如下: <?php for($i = ; $i < 100; $i++) { file_put_contents('dir/file'.$i, ''); } ?> Average time: 0,1145s 代码如下
I has passed a small test to check which function is faster to create a new file.
file_put_contents vs touch
代码如下:
<?php
for($i = ; $i < 100; $i++)
{
file_put_contents('dir/file'.$i, '');
}
?>
Average time: 0,1145s
代码如下:
<?php
for($i = ; $i < 100; $i++)
{
touch('dir/file'.$i);
}
?>
Average time: 0,2322s
所以,
file_put_contents比
touch快,大约两倍。
有用 | 无用
file_put_contents vs touch
代码如下:
<?php
for($i = ; $i < 100; $i++)
{
file_put_contents('dir/file'.$i, '');
}
?>
Average time: 0,1145s
代码如下:
<?php
for($i = ; $i < 100; $i++)
{
touch('dir/file'.$i);
}
?>
Average time: 0,2322s
所以,
file_put_contents比
touch快,大约两倍。
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- 写出高质量的PHP程序
- 组合算法的PHP解答方法
- php处理斐波那契数列非递归方法
- PHP逐行输出(ob_flush与flush的组合)
- 非常好用的两个PHP函数 serialize()和unserialize()
- PHP判断搜索引擎蜘蛛并自动记忆到文件的代码
- PHP的博客ping服务代码
- Ping服务的php实现方法,让网站快速被收录
- PHP常用技巧总结(附函数代码)
- PHP语言中global和$GLOBALS[]的分析 之二
- php中global和$GLOBALS[]的分析之一
- PHP开发者常犯的10个MySQL错误更正剖析
- PHP中全面阻止SQL注入式攻击分析小结
- 几种有用的变型 PHP中循环语句的用法介绍
- 通过PHP修改Linux或Unix口令的方法分享
- php代码收集表单内容并写入文件的代码
- php 无法加载mysql的module的时候的配置的解决方案引发的思考
- php木马webshell扫描器代码
- php addslashes及其他清除空格的方法是不安全的