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

        

  • 相关阅读:
    Java Script 读书笔记 (二) 错误处理机制 -- 没看懂,待review
    Visual Studio Code Tips
    SQLServer数据库分页查询
    Sql server inner join......on
    Sql server if-else以及switch
    git介绍
    Fiddler
    cocos2d对动画的各种操作
    SQLI
    Windows系统命令备份
  • 原文地址:https://www.cnblogs.com/yolo-bean/p/7688566.html
Copyright © 2011-2022 走看看