PHP

PHP file_get_contents函数详解

小云
103
2024-02-05 18:43:04
栏目: 编程语言

PHP的file_get_contents函数用于将一个文件的内容读入一个字符串中。

语法:

string file_get_contents(string $filename [, bool $use_include_path = FALSE [, resource $context [, int $offset = -1 [, int $maxlen = -1]]]])

参数说明:

返回值:

示例:

  1. 读取本地文件的内容:
$content = file_get_contents('test.txt');
echo $content;
  1. 读取URL地址的内容:
$content = file_get_contents('http://example.com');
echo $content;

注意事项:

0
看了该问题的人还看了