コード例 #1
0
ファイル: cls_curl.php プロジェクト: jackyxie/phpspider
 /**
  * 初始化 CURL
  *
  */
 public static function init()
 {
     //if (empty ( self::$ch ))
     if (!is_resource(self::$ch)) {
         self::$ch = curl_init();
         curl_setopt(self::$ch, CURLOPT_RETURNTRANSFER, true);
         curl_setopt(self::$ch, CURLOPT_CONNECTTIMEOUT, self::$timeout);
         curl_setopt(self::$ch, CURLOPT_HEADER, false);
         curl_setopt(self::$ch, CURLOPT_USERAGENT, self::$useragent);
         curl_setopt(self::$ch, CURLOPT_TIMEOUT, self::$timeout + 5);
         // 在多线程处理场景下使用超时选项时,会忽略signals对应的处理函数,但是无耐的是还有小概率的crash情况发生
         curl_setopt(self::$ch, CURLOPT_NOSIGNAL, true);
     }
     return self::$ch;
 }
コード例 #2
0
 public static function init()
 {
     if (empty(self::$ch)) {
         self::$ch = curl_init();
         curl_setopt(self::$ch, CURLOPT_RETURNTRANSFER, true);
         curl_setopt(self::$ch, CURLOPT_CONNECTTIMEOUT, self::$timeout);
         curl_setopt(self::$ch, CURLOPT_HEADER, false);
         curl_setopt(self::$ch, CURLOPT_USERAGENT, self::$useragent);
         curl_setopt(self::$ch, CURLOPT_TIMEOUT, self::$timeout + 5);
     }
     return self::$ch;
 }