PHP curl_error函数

PHP 教程 · 2019-01-23 11:27:47

(PHP 4 >= 4.0.3, PHP 5)

curl_error — 返回一个保护当前会话最近一次错误的字符串

说明

string curl_error ( resource $ch )

返回一条最近一次cURL操作明确的文本的错误信息。

参数

ch

由 curl_init() 返回的 cURL 句柄。

返回值

返回错误信息或 '' (空字符串) 如果没有任何错误发生。

实例

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

参见

点击查看所有 PHP 教程 文章: https://codercto.com/courses/l/5.html

查看所有标签

Weaving the Web

Weaving the Web

Tim Berners-Lee / Harper Paperbacks / 2000-11-01 / USD 15.00

Named one of the greatest minds of the 20th century by Time , Tim Berners-Lee is responsible for one of that century's most important advancements: the world wide web. Now, this low-profile genius-wh......一起来看看 《Weaving the Web》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具