zoukankan      html  css  js  c++  java
  • Curl是什么,原文地址:http://www.phpchina.com/portal.php?mod=view&aid=40161

    1. Curl是什么
      PHP supports libcurl, a library created by Daniel Stenberg, that allows you to connect and communicate to many different types of servers with many different types of protocols.
      Curl是一个库,它允许你通过各种协议和各种不同的服务器进行连接和通讯
    2. 我们以著名的“测试网络是否连接”的网站——百度为例,来尝试下curl
      <?php
        // create curl resource 
        // 创建了一个curl会话资源,成功返回一个句柄; 
         $ch = curl_init(); 
      
         // set url 
         curl_setopt($ch, CURLOPT_URL, "baidu.com"); 
      
         //return the transfer as a string 
         //设置是否将响应结果存入变量,1是存入,0是直接echo出;
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
      
         // $output contains the output string
         // 执行,然后将响应结果存入$output变量,供下面echo; 
         if($output = curl_exec($ch)){
         	//echo output  成功则打开百度页面
          echo $output;
         }else{
         	echo "你尚未连接网络";
         }
         // close curl resource to free up system resources
         // 关闭这个curl会话资源。 
         curl_close($ch);    
      

        

  • 相关阅读:
    window.open跨页面传输
    history对象
    类vr特效的360度全景
    移动端图片滑动
    图片拼图
    20180808 考试记录
    [jzoj 5770]【2018提高组模拟A组8.6】可爱精灵宝贝 (区间dp)
    20180806 考试记录
    [luogu2319 HNOI2006] 超级英雄 (匈牙利算法)
    [luogu2679] 子串 (多维dp)
  • 原文地址:https://www.cnblogs.com/yolo-bean/p/7688566.html
Copyright © 2011-2022 走看看