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);    
      

        

  • 相关阅读:
    js模板引擎-art-template常用总结
    安装 PLSQL笔记
    [转载]软件测试之Web测试经典总结
    网络相关概念笔记
    HTTP请求过程
    Postman newman
    Postman interceptor
    SoupUI学习资料
    Postman 基本操作学习
    Postman 安装 & 资料
  • 原文地址:https://www.cnblogs.com/yolo-bean/p/7688566.html
Copyright © 2011-2022 走看看