龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

fopen php中以只读方式打开文件

时间:2014-06-04 02:05来源:网络整理 作者:网络 点击:
分享到:
php中以只读方式打开文件 [代码片段(8行)] 上面的代码返回如下结果
<?php 
$file = fopen("/tmp/file.txt", "r");
print("Type of file handle: " . gettype($file) . "\n");
print("The first line from the file handle: " . fgets($file));
fclose($file); 
?>

                                上面的代码返回如下结果
Type of file handle: resource
The first line from the file handle: Welcome to outofmemory.cn php tutorials

                                文件读取完成后,需要使用fclose()函数关闭文件句柄,以释放资源
精彩图集

赞助商链接