无需言 做自己 业 ,精于勤 荒于嬉.
- 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_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_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_share_errno 返回共享 curl 句柄的最后一次错误号
-
发表日期:2021-07-01 08:56:37 | 来源: | 分类:cURL 函数
-
- 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_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; } ?>
- cURL 函数 curl_share_strerror 返回错误号对应的错误消息
-
发表日期:2021-07-01 08:56:37 | 来源: | 分类:cURL 函数
-
- cURL 函数 curl_multi_init 返回一个新cURL批处理句柄
-
发表日期:2021-07-01 08:56:37 | 来源: | 分类:cURL 函数
-
示例1
<?php // 创建一对cURL资源$ch1 = curl_init(); $ch2 = curl_init(); // 设置URL和相应的选项curl_setopt($ch1, CURLOPT_URL, "http://www.example.com/"); curl_setopt($ch1, CURLOPT_HEADER, 0); curl_setopt($ch2, CURLOPT_URL, "http://www.php.net/"); curl_setopt($ch2, CURLOPT_HEADER, 0); // 创建批处理cURL句柄$mh = curl_multi_init(); // 增加2个句柄curl_multi_add_handle($mh,$ch1); curl_multi_add_handle($mh,$ch2); $running=null; // 执行批处理句柄do { usleep(10000); curl_multi_exec($mh,$running); } while ($running > 0); // 关闭全部句柄curl_multi_remove_handle($mh, $ch1); curl_multi_remove_handle($mh, $ch2); curl_multi_close($mh); ?>
- 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_file_create 创建一个 CURLFile 对象
-
发表日期:2021-07-01 08:56:36 | 来源: | 分类:cURL 函数
-
curl_file_create
(PHP 5 >= 5.5.0, PHP 7, PHP 8)
curl_file_create — 创建一个 CURLFile 对象
说明
此函数是该函数的别名: CURLFile::__construct()
- cURL 函数 curl_getinfo 获取一个cURL连接资源句柄的信息
-
发表日期:2021-07-01 08:56:36 | 来源: | 分类:cURL 函数
-
示例1
<?php // 创建一个cURL句柄$ch = curl_init('http://www.yahoo.com/'); // 执行curl_exec($ch); // 检查是否有错误发生if(!curl_errno($ch)){ $info = curl_getinfo($ch); echo 'Took ' . $info['total_time'] . ' seconds to send a request to ' . $info['url']; } // Close handlecurl_close($ch); ?>
- cURL 函数 curl_multi_add_handle 向curl批处理会话中添加单独的curl句柄
-
发表日期:2021-07-01 08:56:36 | 来源: | 分类:cURL 函数
-
示例1
<?php // 创建一对cURL资源$ch1 = curl_init(); $ch2 = curl_init(); // 设置URL和相应的选项curl_setopt($ch1, CURLOPT_URL, "http://www.example.com/"); curl_setopt($ch1, CURLOPT_HEADER, 0); curl_setopt($ch2, CURLOPT_URL, "http://www.php.net/"); curl_setopt($ch2, CURLOPT_HEADER, 0); // 创建批处理cURL句柄$mh = curl_multi_init(); // 增加2个句柄curl_multi_add_handle($mh,$ch1); curl_multi_add_handle($mh,$ch2); $running=null; // 执行批处理句柄do { curl_multi_exec($mh,$running); } while($running > 0); // 关闭全部句柄curl_multi_remove_handle($mh, $ch1); curl_multi_remove_handle($mh, $ch2); curl_multi_close($mh); ?>
- cURL 函数 curl_init 初始化 cURL 会话
-
发表日期:2021-07-01 08:56:36 | 来源: | 分类:cURL 函数
-
示例1
<?php // 创建一个新cURL资源$ch = curl_init(); // 设置URL和相应的选项curl_setopt($ch, CURLOPT_URL, "http://www.example.com/"); curl_setopt($ch, CURLOPT_HEADER, 0); // 抓取URL并把它传递给浏览器curl_exec($ch); // 关闭cURL资源,并且释放系统资源curl_close($ch); ?>
- cURL 函数 curl_multi_close 关闭一组cURL句柄
-
发表日期:2021-07-01 08:56:36 | 来源: | 分类:cURL 函数
-
示例1
<?php // 创建一对cURL资源$ch1 = curl_init(); $ch2 = curl_init(); // 设置URL和相应的选项curl_setopt($ch1, CURLOPT_URL, "http://www.example.com/"); curl_setopt($ch1, CURLOPT_HEADER, 0); curl_setopt($ch2, CURLOPT_URL, "http://www.php.net/"); curl_setopt($ch2, CURLOPT_HEADER, 0); // 创建批处理cURL句柄$mh = curl_multi_init(); // 增加2个句柄curl_multi_add_handle($mh,$ch1); curl_multi_add_handle($mh,$ch2); $running=null; // 执行批处理句柄do { curl_multi_exec($mh,$running); } while ($running > 0); // 关闭全部句柄curl_multi_remove_handle($mh, $ch1); curl_multi_remove_handle($mh, $ch2); curl_multi_close($mh); ?>
- cURL 函数 curl_error 返回当前会话最后一次错误的字符串
-
发表日期:2021-07-01 08:56:36 | 来源: | 分类:cURL 函数
-
示例1
<?php // 创建 cURL 句柄,指向一个不存在的位置$ch = curl_init('http://404.php.net/'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); if(curl_exec($ch) === false){ echo 'Curl error: ' . curl_error($ch); } else{ echo '操作完成没有任何错误'; } // 关闭句柄curl_close($ch); ?>
- cURL 函数 curl_close 关闭 cURL 会话
-
发表日期:2021-07-01 08:56:36 | 来源: | 分类:cURL 函数
-
示例1
<?php // 创建一个新cURL资源$ch = curl_init(); // 设置URL和相应的选项curl_setopt($ch, CURLOPT_URL, "http://www.example.com/"); curl_setopt($ch, CURLOPT_HEADER, 0); // 抓取URL并把它传递给浏览器curl_exec($ch); // 关闭cURL资源,并且释放系统资源curl_close($ch); ?>
- cURL 函数 curl_multi_errno 返回上一次 curl 批处理的错误码
-
发表日期:2021-07-01 08:56:36 | 来源: | 分类:cURL 函数
-
curl_multi_errno
(PHP 7 >= 7.1.0, PHP 8)
curl_multi_errno — 返回上一次 curl 批处理的错误码
说明
curl_multi_errno(resource$mh): int返回一个整型数字,为上次 curl 批处理错误码。
参数
-
multi_handle -
由 curl_multi_init() 返回的 cURL 多个句柄。
返回值
返回整型数字,包含上次 curl 批处理的错误码, 或者在失败时返回
false参见
- curl_errno() - 返回最后一次的错误代码
-
- 前端开发(1)
- 数据库(0)
- PHP(0)
- PHP杂项(34)
- PHP基础-李炎恢系列课程(20)
- 中文函数手册(0)
- 错误处理 函数(13)
- OPcache 函数(6)
- PHP 选项/信息 函数(54)
- Zip 函数(10)
- Hash 函数(15)
- OpenSSL 函数(63)
- Date/Time 函数(51)
- 目录函数(9)
- Fileinfo 函数(6)
- iconv 函数(11)
- 文件系统函数(81)
- 多字节字符串 函数(57)
- GD 和图像处理 函数(114)
- 可交换图像信息(5)
- Math 函数(50)
- 程序执行函数(11)
- PCNTL 函数(23)
- JSON 函数(4)
- SPL 函数(15)
- URL 函数(10)
- cURL 函数(32)
- 网络 函数(33)
- FTP 函数(36)
- Session 函数(23)
- PCRE 函数(11)
- PCRE 正则语法(19)
- 数组 函数(81)
- 类/对象 函数(18)
- 函数处理 函数(13)
- 变量处理 函数(37)
- SimpleXML 函数(3)
- 杂项 函数(31)
- 字符串 函数(101)
- JAVA(0)
- Android(0)
- Linux(0)
- AI大模型(9)
- 其他(0)
宁公网安备 64010402001209号