php中file_get_contents函数有什么作用

在php中 , file_get_contents函数主要用于读取文件的内容 。 下面小编举例讲解php中file_get_contents函数有什么作用 。

php中file_get_contents函数有什么作用

文章插图

需要这些哦
php
代码编纂器:z studio 10.0
方式/
1新建一个php文件 , 定名为test.php , 用于讲解php中file_get_contents函数有什么感化 。
php中file_get_contents函数有什么作用

文章插图

2在test.php文件中 , 利用header()方式设置页面的编码格局为utf-8 。
php中file_get_contents函数有什么作用

文章插图

3在test.php文件中 , 将文件的路径保留在$path变量中 , 用于测试 。
php中file_get_contents函数有什么作用

文章插图

4在test.php文件中 , 利用flie_get_contents函数从test.txt文件中获得内容 。
php中file_get_contents函数有什么作用

文章插图

5在test.php文件中 , 利用echo输出文件内容 。
php中file_get_contents函数有什么作用

文章插图

6在浏览器打开test.php文件 , 查看成果 。
php中file_get_contents函数有什么作用

文章插图

总结:11、将文件的路径保留在$path变量中 , 用于测试 。
2、利用flie_get_contents函数从test.txt文件中获得内容 。
3、利用echo输出文件内容 。
【php中file_get_contents函数有什么作用】4、在浏览器打开test.php文件 , 查看成果 。


以上内容就是php中file_get_contents函数有什么作用的内容啦 , 希望对你有所帮助哦!

    推荐阅读