php 不要回应 cURL

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1918383/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 04:18:00  来源:igfitidea点击:

Don't Echo Out cURL

phpcurl

提问by tarnfeld

When I use this code:

当我使用此代码时:

$ch = curl_init($url);
$statuses = curl_exec($ch);
curl_close($ch);

I am returned what I want, but if I just use that - $statusesis echoed out onto the page.

我得到了我想要的东西,但如果我只是使用它 -$statuses会在页面上回显。

How can I stop this?

我怎么能阻止这个?

回答by Matt McCormick

Put this on line 2:

把它放在第 2 行:

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

回答by Dominic Barnes

Include this option before curl_exec()

在此之前包含此选项 curl_exec()

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);