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

2015-01-24信息快讯网

php中用file_put_contents比touch快,大约两倍左右。

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快,大约两倍。
深入eAccelerator与memcached的区别详解
探讨file_get_contents与curl效率及稳定性的分析
php将gd生成的图片缓存到memcache的小例子
php htmlspecialchars()与shtmlspecialchars()函数的深入分析
深入理解用mysql_fetch_row()以数组的形式返回查询结果
fetchAll()与mysql_fetch_array()的区别详解
PHP register_shutdown_function函数的深入解析
解析CI即CodeIgniter框架在Nginx下的重写规则
深入php函数file_get_contents超时处理的方法详解
详解PHP内置访问资源的超时时间 time_out file_get_contents read_file
ubuntu10.04配置 nginx+php-fpm模式的详解
解析php DOMElement 操作xml 文档的实现代码
input file获得文件根目录简单实现
file_get_contents获取不到网页内容的解决方法
php addslashes及其他清除空格的方法是不安全的
php中将数组存到文件里的实现代码
Uncaught exception com_exception with message Failed to create COM object
比file_get_contents稳定的curl_get_contents分享
php mysql 判断update之后是否更新了的方法
shopex主机报错误请求解决方案(No such file or directory)
如何使用Linux的Crontab定时执行PHP脚本的方法
PHP spl_autoload_register实现自动加载研究
PHP性能优化工具篇Benchmark类调试执行时间
php的chr和ord函数实现字符加减乘除运算实现代码
PHP函数篇之掌握ord()与chr()函数应用
PHP循环语句笔记(foreach,list)
php数组函数序列之array_intersect() 返回两个或多个数组的交集数组
php数组函数序列 之array_count_values() 统计数组中所有值出现的次数函数
Array of country list in PHP with Zend Framework
PHP-CGI进程CPU 100% 与 file_get_contents 函数的关系分析
php中使用Curl、socket、file_get_contents三种方法POST提交数据
Can't create/write to file 'C:\WINDOWS\TEMP\...MYSQL报错解决方法
©2014-2024 dbsqp.com