PHP file() 函数
PHP 教程
· 2019-01-24 21:14:18
定义和用法
file() 函数把整个文件读入一个数组中。
数组中的每个元素都是文件中相应的一行,包括换行符在内。
语法
file(path,include_path,context)
| 参数 | 描述 |
|---|---|
| path | 必需。规定要读取的文件。 |
| include_path | 可选。如果您还想在 include_path(在 php.ini 中)中搜索文件的话,请设置该参数为 '1'。 |
| context | 可选。规定文件句柄的环境。context 是一套可以修改流的行为的选项。若使用 NULL,则忽略。 |
提示和注释
提示:从 PHP 4.3 开始,该函数是二进制安全的。(意思是二进制数据(如图像)和字符数据都可以使用此函数写入。)
实例
<?php
print_r(file("test.txt"));
?>
上面的代码将输出:
Array ( [0] => Hello World. Testing testing! [1] => Another day, another line. [2] => If the array picks up this line, [3] => then is it a pickup line? )
点击查看所有 PHP 教程 文章: https://codercto.com/courses/l/5.html
Usability for the Web
Tom Brinck、Darren Gergle、Scott D. Wood / Morgan Kaufmann / 2001-10-15 / USD 65.95
Every stage in the design of a new web site is an opportunity to meet or miss deadlines and budgetary goals. Every stage is an opportunity to boost or undercut the site's usability. Thi......一起来看看 《Usability for the Web》 这本书的介绍吧!