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

PHP file_get_contents() 函数

 函数原型

/**

 * 把整个文件读入一个字符串中,二进制安全

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

 * @param string $filename  要读的文件名或URL

 * @param int $flags [optional]  如果要在 include_path(在 php.ini 中)中搜索文件,需设置该参数为 '1'。

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

 * @param int $offset [optional]  在文件中开始读取的位置

 * @param int $maxlen [optional]  读取的字节数

 * @return string 返回读取的数据,失败返回 false

 * @since 4.3.0

 * @since 5.0

 */

function file_get_contents ($filename, $flags = null, $context = null, $offset = null, $maxlen = null) {}

 

函数示例

<?php

echo file_get_contents("test.txt");

?>

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


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