managing curl output in php
How do I hide the output from curl in PHP?
My code as it stands is the following:
$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?
php curl
add a comment |
How do I hide the output from curl in PHP?
My code as it stands is the following:
$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?
php curl
add a comment |
How do I hide the output from curl in PHP?
My code as it stands is the following:
$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?
php curl
How do I hide the output from curl in PHP?
My code as it stands is the following:
$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?
php curl
php curl
edited Sep 12 '14 at 19:41
Eric Leschinski
88.2k40323277
88.2k40323277
asked Aug 5 '09 at 17:08
mrpatgmrpatg
4,9173696151
4,9173696151
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Use this option to curl_setopt():
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
This will make curl_exec return the data instead of outputting it.
To see if it was successful you can then check $result and also curl_error().
2
works great, thank you sir
– mrpatg
Aug 5 '09 at 17:18
Thanks, this is solid
– Zack Shapiro
May 7 '15 at 17:05
I've read from stackoverflow.com/a/18203696/2495584 that it uses 1 as the second paramater. Which is the better one to use?
– Gellie Ann
Jan 4 '17 at 8:42
0/False and 1/True are interchangeable as boolean data types. So, it's exactly the same thing, take your pick.
– mrpatg
Jul 11 '18 at 16:39
add a comment |
Also make sure to turn off this option:
curl_setopt($ch, CURLOPT_VERBOSE, 0);
Or else it will still print everything to screen.
else it will still print everything to screen- no it won't, CURLOPT_VERBOSE is 0 by default, and always has been.
– hanshenrik
Nov 15 '18 at 13:30
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f1234537%2fmanaging-curl-output-in-php%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Use this option to curl_setopt():
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
This will make curl_exec return the data instead of outputting it.
To see if it was successful you can then check $result and also curl_error().
2
works great, thank you sir
– mrpatg
Aug 5 '09 at 17:18
Thanks, this is solid
– Zack Shapiro
May 7 '15 at 17:05
I've read from stackoverflow.com/a/18203696/2495584 that it uses 1 as the second paramater. Which is the better one to use?
– Gellie Ann
Jan 4 '17 at 8:42
0/False and 1/True are interchangeable as boolean data types. So, it's exactly the same thing, take your pick.
– mrpatg
Jul 11 '18 at 16:39
add a comment |
Use this option to curl_setopt():
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
This will make curl_exec return the data instead of outputting it.
To see if it was successful you can then check $result and also curl_error().
2
works great, thank you sir
– mrpatg
Aug 5 '09 at 17:18
Thanks, this is solid
– Zack Shapiro
May 7 '15 at 17:05
I've read from stackoverflow.com/a/18203696/2495584 that it uses 1 as the second paramater. Which is the better one to use?
– Gellie Ann
Jan 4 '17 at 8:42
0/False and 1/True are interchangeable as boolean data types. So, it's exactly the same thing, take your pick.
– mrpatg
Jul 11 '18 at 16:39
add a comment |
Use this option to curl_setopt():
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
This will make curl_exec return the data instead of outputting it.
To see if it was successful you can then check $result and also curl_error().
Use this option to curl_setopt():
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
This will make curl_exec return the data instead of outputting it.
To see if it was successful you can then check $result and also curl_error().
answered Aug 5 '09 at 17:10
GregGreg
256k47338321
256k47338321
2
works great, thank you sir
– mrpatg
Aug 5 '09 at 17:18
Thanks, this is solid
– Zack Shapiro
May 7 '15 at 17:05
I've read from stackoverflow.com/a/18203696/2495584 that it uses 1 as the second paramater. Which is the better one to use?
– Gellie Ann
Jan 4 '17 at 8:42
0/False and 1/True are interchangeable as boolean data types. So, it's exactly the same thing, take your pick.
– mrpatg
Jul 11 '18 at 16:39
add a comment |
2
works great, thank you sir
– mrpatg
Aug 5 '09 at 17:18
Thanks, this is solid
– Zack Shapiro
May 7 '15 at 17:05
I've read from stackoverflow.com/a/18203696/2495584 that it uses 1 as the second paramater. Which is the better one to use?
– Gellie Ann
Jan 4 '17 at 8:42
0/False and 1/True are interchangeable as boolean data types. So, it's exactly the same thing, take your pick.
– mrpatg
Jul 11 '18 at 16:39
2
2
works great, thank you sir
– mrpatg
Aug 5 '09 at 17:18
works great, thank you sir
– mrpatg
Aug 5 '09 at 17:18
Thanks, this is solid
– Zack Shapiro
May 7 '15 at 17:05
Thanks, this is solid
– Zack Shapiro
May 7 '15 at 17:05
I've read from stackoverflow.com/a/18203696/2495584 that it uses 1 as the second paramater. Which is the better one to use?
– Gellie Ann
Jan 4 '17 at 8:42
I've read from stackoverflow.com/a/18203696/2495584 that it uses 1 as the second paramater. Which is the better one to use?
– Gellie Ann
Jan 4 '17 at 8:42
0/False and 1/True are interchangeable as boolean data types. So, it's exactly the same thing, take your pick.
– mrpatg
Jul 11 '18 at 16:39
0/False and 1/True are interchangeable as boolean data types. So, it's exactly the same thing, take your pick.
– mrpatg
Jul 11 '18 at 16:39
add a comment |
Also make sure to turn off this option:
curl_setopt($ch, CURLOPT_VERBOSE, 0);
Or else it will still print everything to screen.
else it will still print everything to screen- no it won't, CURLOPT_VERBOSE is 0 by default, and always has been.
– hanshenrik
Nov 15 '18 at 13:30
add a comment |
Also make sure to turn off this option:
curl_setopt($ch, CURLOPT_VERBOSE, 0);
Or else it will still print everything to screen.
else it will still print everything to screen- no it won't, CURLOPT_VERBOSE is 0 by default, and always has been.
– hanshenrik
Nov 15 '18 at 13:30
add a comment |
Also make sure to turn off this option:
curl_setopt($ch, CURLOPT_VERBOSE, 0);
Or else it will still print everything to screen.
Also make sure to turn off this option:
curl_setopt($ch, CURLOPT_VERBOSE, 0);
Or else it will still print everything to screen.
answered Sep 12 '14 at 19:40
Eric LeschinskiEric Leschinski
88.2k40323277
88.2k40323277
else it will still print everything to screen- no it won't, CURLOPT_VERBOSE is 0 by default, and always has been.
– hanshenrik
Nov 15 '18 at 13:30
add a comment |
else it will still print everything to screen- no it won't, CURLOPT_VERBOSE is 0 by default, and always has been.
– hanshenrik
Nov 15 '18 at 13:30
else it will still print everything to screen - no it won't, CURLOPT_VERBOSE is 0 by default, and always has been.– hanshenrik
Nov 15 '18 at 13:30
else it will still print everything to screen - no it won't, CURLOPT_VERBOSE is 0 by default, and always has been.– hanshenrik
Nov 15 '18 at 13:30
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f1234537%2fmanaging-curl-output-in-php%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown