cURL 函数 业 ,精于勤 荒于嬉.

cURL 函数 curl_pause 暂停和取消暂停一个连接。

发表日期:2021-07-01 08:56:37 | 来源: | 分类:cURL 函数

curl_pause

(PHP 5 >= 5.5.0, PHP 7, PHP 8)

curl_pause暂停和取消暂停一个连接。

说明

curl_pause(resource $ch, int $bitmask): int

警告

本函数还未编写文档,仅有参数列表。

参数

handle

curl_init() 返回的 cURL 句柄。

bitmask

CURLPAUSE_* 常量之一。

返回值

返回一个错误代码 (如果没有错误则返回CURLE_OK常量)。

阅读全文 »

cURL 函数 curl_reset 重置一个 libcurl 会话句柄的所有的选项

发表日期:2021-07-01 08:56:37 | 来源: | 分类:cURL 函数

      示例1
<?php 
// 创建一个url 句柄$ch = curl_init();
// 设置 CURLOPT_USERAGENT 选项curl_setopt($ch, CURLOPT_USERAGENT, "My test user-agent");
// 重置所有的预先设置的选项curl_reset($ch);
// 发送 HTTP 请求curl_setopt($ch, CURLOPT_URL, 'http://example.com/');
curl_exec($ch);
 // 预先设置的 user-agent 不会被发送,它已经被 curl_reset 重置掉了// 关闭句柄curl_close($ch);
?>

阅读全文 »

cURL 函数 curl_setopt_array 为 cURL 传输会话批量设置选项

发表日期:2021-07-01 08:56:37 | 来源: | 分类:cURL 函数

      示例1
<?php 
// 创建一个新 cURL 资源$ch = curl_init();
// 设置 URL 和相应的选项$options = array(CURLOPT_URL => 'http://www.example.com/',                 CURLOPT_HEADER => false                );
curl_setopt_array($ch, $options);
// 抓取 URL 并把它传递给浏览器curl_exec($ch);
// 关闭 cURL 资源,并且释放系统资源curl_close($ch);
?>

      示例2
<?php 
if (!function_exists('curl_setopt_array')) {
   function curl_setopt_array(&$ch, $curl_options)   {
       foreach ($curl_options as $option => $value) {
           if (!curl_setopt($ch, $option, $value)) {
               return false;
           }
        }
       return true;
   }
}
?>

阅读全文 »

cURL 函数 curl_setopt 设置 cURL 传输选项

发表日期:2021-07-01 08:56:37 | 来源: | 分类:cURL 函数

      示例1
<?php 
// 创建一个新cURL资源$ch = curl_init();
// 设置URL和相应的选项curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");
curl_setopt($ch, CURLOPT_HEADER, false);
// 抓取URL并把它传递给浏览器curl_exec($ch);
//关闭cURL资源,并且释放系统资源curl_close($ch);
?>

      示例2
<?php 
/* http://localhost/upload.php:print_r($_POST);
print_r($_FILES);
*/
$ch = curl_init();
$data = array('name' => 'Foo', 'file' => '@/home/user/test.png');
curl_setopt($ch, CURLOPT_URL, 'http://localhost/upload.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false);
 //  PHP 5.6.0 后必须开启curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_exec($ch);
?>

阅读全文 »

cURL 函数 curl_share_close 关闭 cURL 共享句柄

发表日期:2021-07-01 08:56:37 | 来源: | 分类:cURL 函数

      示例1
<?php 
// Create cURL share handle and set it to share cookie data$sh = curl_share_init();
curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
// Initialize the first cURL handle and assign the share handle to it$ch1 = curl_init("http://example.com/");
curl_setopt($ch1, CURLOPT_SHARE, $sh);
// Execute the first cURL handlecurl_exec($ch1);
// Initialize the second cURL handle and assign the share handle to it$ch2 = curl_init("http://php.net/");
curl_setopt($ch2, CURLOPT_SHARE, $sh);
// Execute the second cURL handle//  all cookies from $ch1 handle are shared with $ch2 handlecurl_exec($ch2);
// Close the cURL share handlecurl_share_close($sh);
// Close the cURL handlescurl_close($ch1);
curl_close($ch2);
?>

阅读全文 »

cURL 函数 curl_share_errno 返回共享 curl 句柄的最后一次错误号

发表日期:2021-07-01 08:56:37 | 来源: | 分类:cURL 函数

curl_share_errno

(PHP 7 >= 7.1.0, PHP 8)

curl_share_errno返回共享 curl 句柄的最后一次错误号

说明

curl_share_errno(resource $sh): int

返回一个整数,表示共享 curl 句柄的最后一次错误号

参数

sh

curl_share_init() 函数创建的共享 cURL 句柄。

返回值

返回一个整数,表示共享 curl 句柄的最后一次错误号, 或者在失败时返回 false

参见

阅读全文 »

cURL 函数 curl_share_init 初始化一个 cURL 共享句柄。

发表日期:2021-07-01 08:56:37 | 来源: | 分类:cURL 函数

      示例1
<?php 
// 创建 cURL 共享句柄,并设置共享 cookie 数据$sh = curl_share_init();
curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
// 初始化第一个 cURL 句柄,并将它设置到共享句柄$ch1 = curl_init("http://example.com/");
curl_setopt($ch1, CURLOPT_SHARE, $sh);
// 执行第一个 cURL 句柄curl_exec($ch1);
// 初始化第二个 cURL 句柄,并将它设置到共享句柄$ch2 = curl_init("http://php.net/");
curl_setopt($ch2, CURLOPT_SHARE, $sh);
// 执行第二个 cURL 句柄//  all cookies from $ch1 handle are shared with $ch2 handlecurl_exec($ch2);
// 关闭 cURL 共享句柄curl_share_close($sh);
// 关闭 cURL 共享句柄curl_close($ch1);
curl_close($ch2);
?>

阅读全文 »

cURL 函数 curl_share_setopt 为 cURL 共享句柄设置选项。

发表日期:2021-07-01 08:56:37 | 来源: | 分类:cURL 函数

      示例1
<?php 
// Create cURL share handle and set it to share cookie data$sh = curl_share_init();
curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
// Initialize the first cURL handle and assign the share handle to it$ch1 = curl_init("http://example.com/");
curl_setopt($ch1, CURLOPT_SHARE, $sh);
// Execute the first cURL handlecurl_exec($ch1);
// Initialize the second cURL handle and assign the share handle to it$ch2 = curl_init("http://php.net/");
curl_setopt($ch2, CURLOPT_SHARE, $sh);
// Execute the second cURL handle//  all cookies from $ch1 handle are shared with $ch2 handlecurl_exec($ch2);
// Close the cURL share handlecurl_share_close($sh);
// Close the cURL handlescurl_close($ch1);
curl_close($ch2);
?>

阅读全文 »

cURL 函数 curl_share_strerror 返回错误号对应的错误消息

发表日期:2021-07-01 08:56:37 | 来源: | 分类:cURL 函数

curl_share_strerror

(PHP 7 >= 7.1.0, PHP 8)

curl_share_strerror返回错误号对应的错误消息

说明

curl_share_strerror(int $errornum): string

返回错误号对应的错误消息。

参数

errornum

» cURL error codes 常量。

返回值

返回错误消息。如果传入了无效的错误号,返回 null

参见

阅读全文 »

cURL 函数 curl_strerror 返回错误代码的字符串描述

发表日期:2021-07-01 08:56:37 | 来源: | 分类:cURL 函数

      示例1
<?php 
// 以错拼的 URL 协议创建 curl 句柄$ch = curl_init("htp://example.com/");
// 发送请求curl_exec($ch);
// 检测错误,显示错误信息if($errno = curl_errno($ch)) {
    $error_message = curl_strerror($errno);
    echo "cURL error ({
$errno}
):\n {
$error_message}
";
}
// 关闭句柄curl_close($ch);
?>

阅读全文 »

cURL 函数 curl_unescape 解码给定的 URL 编码的字符串

发表日期:2021-07-01 08:56:37 | 来源: | 分类:cURL 函数

      示例1
<?php 
// 创建一个 curl 句柄$ch = curl_init('http://example.com/redirect.php');
// 发送 HTTP 请求并且遵循重定向curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_exec($ch);
// 获取最后的有效 URL$effective_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
// 结果: "http://example.com/show_location.php?loc=M%C3%BCnchen"// 解码这个 URL$effective_url_decoded = curl_unescape($ch, $effective_url);
// "http://example.com/show_location.php?loc=München"// 关闭句柄curl_close($ch);
?>

阅读全文 »

cURL 函数 curl_version 获取 cURL 版本信息

发表日期:2021-07-01 08:56:37 | 来源: | 分类:cURL 函数

      示例1
<?php 
// 获取cURL版本数组$version = curl_version();
// 在cURL编译版本中使用位域来检查某些特性$bitfields = Array(            'CURL_VERSION_IPV6',             'CURL_VERSION_KERBEROS4',             'CURL_VERSION_SSL',             'CURL_VERSION_LIBZ'            );
foreach($bitfields as $feature){
    echo $feature . ($version['features'] & constant($feature) ? ' matches' : ' does not match');
    echo PHP_EOL;
}
?>

阅读全文 »

全部博文(1589)
集速网 copyRight © 2015-2025 宁ICP备15000399号-1 宁公网安备 64010402001209号
与其临渊羡鱼,不如退而结网
欢迎转载、分享、引用、推荐、收藏。