zoukankan      html  css  js  c++  java
  • php中几个文件读取函数的贴心功能

    1. <?php
    2. $html = file_get_contents('http://www.example.com/');
    3. print_r($http_response_header);
    4.  
    5. // or
    6. $fp = fopen('http://www.example.com/', 'r');
    7. print_r(stream_get_meta_data($fp));
    8. fclose($fp);
    9. ?>

    示例代码2:

    1. <?php
    2. $data = array ('foo' => 'bar');
    3. $data = http_build_query($data);
    4.  
    5. $opts = array (
    6.     'http' => array (
    7.         'method' => 'POST',
    8.         'header'=> "Content-type: application/x-www-form-urlencoded\r\n" .
    9.                    "Content-Length: " . strlen($data) . "\r\n",
    10.         'content' => $data
    11.     ),
    12. );
    13.  
    14. $context = stream_context_create($opts);
    15. $html = file_get_contents('http://www.example.com', false, $context);
    16.  
    17. echo $html;
    18. ?>
    19. from:http://www.ugia.cn/?p=140
  • 相关阅读:
    SpringDataRedis 常用命令
    Java 连接 Redis
    Java 循环标记
    初学Docker
    线程池,进程和线程的理解
    Linux-定时器任务
    Linux 命令2
    Linux命令
    Java基础整理
    微服务简介
  • 原文地址:https://www.cnblogs.com/kuyuecs/p/1557437.html
Copyright © 2011-2022 走看看