fopen php中以只读方式打开文件
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()函数关闭文件句柄,以释放资源
- 上一篇:count php获取数组的长度函数
- 下一篇:php过滤XSS攻击的函数
精彩图集
精彩文章