php中file_get_contents()函数用法实例
更新时间:2019年02月21日 11:00:53 投稿:laozhang
在本文中我们给大家整理了关于php中file_get_contents()函数的相关用法,需要的朋友们学习参考下。
我们先来看一下php中的 file_get_contents()函数的语法
string file_get_contents(string $ filename,bool $ include_path = false,resource $ context,int $ offset = 0,int $ maxlen)
- filename是文件或URL的名称。
- include_path如果启用,则在include_path中搜索文件
- context这是用于修改流的行为的选项集
- offset此值指定要读取的文件的起始位置。
- maxlen此值指定要读取的字节数。
将文件内容读取为字符串
这个php示例将从文件中读取内容并存储到字符串变量中。
<?php $ content = file_get_contents(“input.txt”); echo $ content; ?>
将内容从URL读取到字符串
<?php $content = file_get_contents("http://example.com"); echo $content; ?>
以上就是关于php中file_get_contents()函数的相关知识点,感谢大家的阅读和对脚本之家的支持。
相关文章
phpMyAdmin出现无法载入 mcrypt 扩展,请检查PHP配置的解决方法
出现以下几种情况后可能会造成运行phpmyadmin程序提示 无法载入 mcrypt 扩展,请检查 PHP 配置 的 错误提示2012-03-03对php 判断http还是https,以及获得当前url的方法详解
今天小编就为大家分享一篇对php 判断http还是https,以及获得当前url的方法详解,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧2019-01-01
最新评论