VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > PHP >
  • php中file_get_contents()函数用法实例

在本文中我们给大家整理了关于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示例将从文件中读取内容并存储到字符串变量中。

  1. <?php  
  2.  $ content = file_get_contents(“input.txt”);  
  3.  echo $ content;  
  4. ?> 

将内容从URL读取到字符串

  1. <?php 
  2.  $content = file_get_contents("http://example.com"); 
  3.  echo $content
  4. ?>
  5.  

出处:http://www.phpfensi.com/php/20211110/18482.html
 


相关教程