在 php 中管理 curl 输出 [英] managing curl output in php
本文介绍了在 php 中管理 curl 输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在 PHP 中隐藏 curl 的输出?
How do I hide the output from curl in PHP?
我的代码如下:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, PSSWDINFO);
$result= curl_exec ($ch);
curl_close ($ch);
问题是整个页面都吐出来了,我怎么能简单地显示成功"或失败"的消息?
The problem is that is spews out the entire page, how can I simply show a "success" or "failed" message?
推荐答案
使用此选项curl_setopt()代码>
:
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
这将使 curl_exec
返回数据而不是输出数据.
This will make curl_exec
return the data instead of outputting it.
要查看它是否成功,您可以检查 $result
和 curl_error()
.
To see if it was successful you can then check $result
and also curl_error()
.
这篇关于在 php 中管理 curl 输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文