Example #1
0
 public function __construct($url)
 {
     if (extension_loaded('curl')) {
         //实例化curl类
         $curl = new Curl('get', $url);
         //TODO可以用Regiter去保存
         $this->output = $curl->output;
     } else {
         //实例化Socket类 并传入url和设置超时时常
         $socket = new Socket($url, 10);
         //调用getMethod去模拟GET请求
         $socket->getMethod();
         //获取响应body
         $this->output = $socket->getResponseBody();
     }
 }