file_get_contents — 将整个文件读入一个字符串说明string file_get_contents ( string $filename [, bool $use_include_path [, resource $context [, int $offset [, int $maxlen ]]]] )和 file() 一样,只除了 file_get_contents() 把文件读入一个字符串。将在参数 offset 所指定的位置开始读取长度为 maxlen 的内容。如果失败,file_get_contents() 将返回 FALSE。 file_get_contents() 函数是用来将文件的内容读入到一个字符串中的首选方法。如果操作系统支持还会使用内存映射技术来增强性能。 Note: 如果要打开有特殊字符的 URL (比如说有空格),就需要使用 urlencode() 进行 URL 编码。 Note: context 参数可以用 NULL 来忽略。
file_get_contents(path,include_path,context,start,max_length)
可选。规定文件句柄的环境。
context 是一套可以修改流的行为的选项。若使用 null,则忽略。
对 context 的支持是 PHP 5.0.0 添加的。
注释:本函数可安全用于二进制对象。
<?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? )
Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved. 闵涛 E_mail:admin@mintao.net(欢迎提供学习资源)
鄂公网安备 42011102001154号
站长:MinTao ICP备案号:鄂ICP备11006601号-18