首页 > PHP教程 > PHP常用函数手册 > PHP 文件系统函数

PHP file() 函数

 函数原型

/**

 * 整个文件读入一个数组中,数组中的每个元素都是文件中相应的一行

 * @link http://php.net/manual/en/function.file.php

 * @param string $filename  要读取的文件路径

 * @param int $flags [optional]  FILE_USE_INCLUDE_PATH:在 include_path 中查找文件。FILE_IGNORE_NEW_LINES:在数组每个元素的末尾不要添加换行符。FILE_SKIP_EMPTY_LINES:跳过空行

 * @param resource $context [optional]  文件句柄的环境。context 是一套可以修改流的行为的选项。若使用 NULL,则忽略。

 * @return array the file in an array. 

 * @since 4.0

 * @since 5.0

 */

function file ($filename, $flags = null, $context = null) {}

 

函数示例

<?php

print_r(file("a.txt"));

?>

关闭
感谢您的支持,我会继续努力!
扫码打赏,建议金额1-10元


提醒:打赏金额将直接进入对方账号,无法退款,请您谨慎操作。