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://www.codercto.com/courses/l/5.html

查看所有标签

Head First jQuery

Head First jQuery

Ryan Benedetti , Ronan Cranley / O'Reilly Media / 2011-9 / USD 39.99

Want to add more interactivity and polish to your websites? Discover how jQuery can help you build complex scripting functionality in just a few lines of code. With Head First jQuery, you'll quickly g......一起来看看 《Head First jQuery》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具