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怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号