PHP中file_get_contents函数的用法
这篇文章将为大家详细讲解有关PHP中file_get_contents函数的用法,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
file_get_contents() 把整个文件读入一个字符串中。
该函数是用于把文件的内容读入到一个字符串中的首选方法。如果服务器操作系统支持,还会使用内存映射技术来增强性能。
使用示例
<?php$homepage = file_get_contents('http://www.example.com/');echo $homepage;?>
<?php// <= PHP 5$file = file_get_contents('./people.txt', true);// > PHP 5$file = file_get_contents('./people.txt', FILE_USE_INCLUDE_PATH);?>
<?php// Read 14 characters starting from the 21st character$section = file_get_contents('./people.txt', NULL, NULL, 20, 14);var_dump($section);?>string(14) "lle Bjori Ro"
关于PHP中file_get_contents函数的用法就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。