PHP 函数 file_get_contents 怎么用?-PHP问题

资源魔 41 0

PHP 函数 file_get_contents 怎样用?

正在PHP中file_get_contents函数的作用是将整个文件读入一个字符串,其语法为“file_get_contents($filename) ”,前往值为读掏出来的字符,应用办法只要将文件门路传入$filename便可。

应用示例

<?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》

以上就是PHP 函数 file_get_contents 怎样用?的具体内容,更多请存眷资源魔其它相干文章!

标签: php php教程 file_get_contents php故障解决 php使用问题

抱歉,评论功能暂时关闭!