LAMP之路

不积跬步,无以至千里!

[PHP函数]PHP文件系统函数

2012-10-18 一抹阳光

<pre>
<?php
/*PHP文件系统函数
*2009.12.08
*/
//1.file()
echo ‘<b>1.file()</b><br />’;
//将文件作为一个数组返回。数组中的每个单元都是文件中相应的一行,包括换行符在内。如果失败 file() 返回 FALSE。
//$content = file(“dir.php”);
//var_dump($content);
echo ‘—————————————————<br />’;

//2.file_get_contents()、file_put_contents()
echo ‘<b>2.file_get_contents()、file_put_contents() </b><br />’;
//file_get_contents(‘文件名’);//函数是用来将文件的内容读入到一个字符串中的首选方法。
//file_put_contents(‘文件名’,$content,FILE_APPEND+LOCK_EX);//函数可加第三个参数:FILE_USE_INCLUDE_PATH,FILE_APPEND 和/或 (获得一个独占锁定)
echo ‘—————————————————<br />’;

//3.fopen()、flock()、fread()、fwrite()、fclose()
echo ‘<b>2.fopen()、flock()、fread()、fwrite()、fclos