【PHP】file_get_contents 读入文件函数详解

admin 2021年4月3日19:00:01评论155 views字数 1380阅读4分36秒阅读模式

    PHP file_get_contents 读入文件到字符串函数详解,PHP file_get_contents 读入文件到字符串函数,PHP file_get_contents 读入文件到字符串详解,PHP file_get_contents 读入文件函数详解,PHP file_get_contents 读入文件到字符串,PHP file_get_contents 读文件函数详解,PHP file_get_contents 读入文件函数,PHP file_get_contents 读入文件详解,PHP file_get_contents 读文件函数,PHP file_get_contents 读文件详解,PHP file_get_contents 读入文件,PHP file_get_contents 读文件,PHP file_get_contents,file_get_contents,file_get_contents(path, include_path, context, start, max_length),file_get_contents() 函数,把整个文件读入一个字符串中,和 file() 一样,file_get_contents(),内存映射技术来增强性能,path 必需。规定要读取的文件,include_path 可选,context可选。规定文件句柄的环境,context 是一套可以修改流的行为的选项,start 可选。规定在文件中开始读取的位置,max_length 可选。规定读取的字节数,对 context 参数的支持是 PHP 5.0.0 添加的,本函数可安全用于二进制对象,echo file_get_contents("test.txt");,echo file_get_contents(http://www.baidu.com/);。

PHP file_get_contents 读入文件到字符串函数详解:

函数语法:
    file_get_contents(path, include_path, context, start, max_length)

函数简介:
  file_get_contents() 函数把整个文件读入一个字符串中。

    和 file() 一样,不同的是 file_get_contents() 把文件读入一个字符串。

    file_get_contents() 函数是用于将文件的内容读入到一个字符串中的首选方法。

    如果操作系统支持,还会使用内存映射技术来增强性能。

函数参数:
    参数           描述
    path           必需。规定要读取的文件。
    include_path   可选。如果也想在 include_path 中搜寻文件的话,可以将该参数设为 "1"。
    context        可选。规定文件句柄的环境。
                 context 是一套可以修改流的行为的选项。若使用 null,则忽略。
    start          可选。规定在文件中开始读取的位置。该参数是 PHP 5.1 新加的。
    max_length     可选。规定读取的字节数。该参数是 PHP 5.1 新加的。

函数说明:
    对 context 参数的支持是 PHP 5.0.0 添加的。

提示和注释:
    注释:本函数可安全用于二进制对象。

使用示例:
    读取文件输出:
    php
      echo file_get_contents("test.txt");
  ?>
    输出:This is a test file with test text.

    读取URL Html源码输出:
          echo file_get_contents("http://www.baidu.com/");
  ?>

文章来源于lcx.cc:【PHP】file_get_contents 读入文件函数详解

相关推荐: 马路杀手之:高速出口注意左侧直行车道车辆突然右转变道

视频: 马路杀手之:高速出口注意左侧直行车道车辆突然右转变道 标题:马路杀手之:高速出口注意左侧直行车道车辆突然右转变道 系列:新手驾车上路实用注意事项宝典系列第一集 作者:Nuclear'Atk(核攻击) 网址:https://lcx.cc/ 说明:视频内容…

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年4月3日19:00:01
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   【PHP】file_get_contents 读入文件函数详解http://cn-sec.com/archives/319522.html

发表评论

匿名网友 填写信息