您好,欢迎访问一九零五行业门户网

php file_get_contents 函数_PHP教程

php file_get_contents 函数 
file_get_contents
( php 4中“ = 4.3.0 , php 5中)
file_get_contents -读取整个文件转换成字符串
描述
字符串file_get_contents (字符串$文件[摘要$国旗= 0 [ ,资源$背景[摘要$抵消= -1 [摘要$ maxlen = -1 ] ] ] ] )
这个功能类似文件( ) ,但file_get_contents ( )返回的字符串中的文件,开始在指定的抵消最多maxlen字节。如果失败, file_get_contents ( )将返回false 。
file_get_contents ( )是首选的方式读取文件内容为一个字符串。它将使用内存映射技术的支持下,如果您的操作系统,以提高性能。
注:如果您打开的uri的特殊字符,如空格,你需要的uri的编码进行urlencode ( ) 。
参数
文件名
文件名改为。
旗帜
警告
所有之前的版本的php 6 ,此参数被称为use_include_path是布尔。国旗参数只适用于自php 6 。如果您使用的是旧版本,并希望搜索的文件名中包含路径,这个参数必须是真实的。自php 6 ,您必须使用file_use_include_path国旗代替。
国旗的价值可任意组合下列旗帜(与一些限制) ,加入的二进位或( | )操作符。
可悬挂国旗描述
file_use_include_path搜索文件名中包含目录。见include_path中获取更多信息。
file_text自php 6 ,默认编码的读取数据是utf - 8的。您可以指定一个不同的编码,建立一个自定义的范围内,或通过改变默认使用stream_default_encoding ( ) 。此标志不能用于file_binary 。
file_binary有了这个标志,该文件是只读二进制模式。这是默认设置,并不能用于file_text 。
背景
资源的有效范围内建立stream_context_create ( ) 。如果你不需要使用自定义的情况下,可以跳过此参数为null 。
抵消
抵销在读启动。
maxlen
最大长度的数据读取。
返回值
该函数返回读取数据或false的失败。
实例
例如# 1 get和输出源的网页,网站
$homepage = file_get_contents('http://www.example.com/');
echo $homepage;
?>
example #2 searching within the include_path
// $file = file_get_contents('./people.txt', true);
// > php 5
$file = file_get_contents('./people.txt', file_use_include_path);
?>
http://www.bkjia.com/phpjc/445473.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/445473.htmltecharticlephp file_get_contents 函数 file_get_contents ( php 4中 = 4.3.0 , php 5中) file_get_contents -读取整个文件转换成字符串 描述 字符串file_get_contents (字符...
其它类似信息

推荐信息