managing curl output in php










67















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?










share|improve this question




























    67















    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?










    share|improve this question


























      67












      67








      67


      11






      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?










      share|improve this question
















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      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






















          2 Answers
          2






          active

          oldest

          votes


















          170














          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().






          share|improve this answer


















          • 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


















          15














          Also make sure to turn off this option:



          curl_setopt($ch, CURLOPT_VERBOSE, 0); 


          Or else it will still print everything to screen.






          share|improve this answer























          • 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










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



          );













          draft saved

          draft discarded


















          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









          170














          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().






          share|improve this answer


















          • 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















          170














          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().






          share|improve this answer


















          • 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













          170












          170








          170







          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().






          share|improve this answer













          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().







          share|improve this answer












          share|improve this answer



          share|improve this answer










          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












          • 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













          15














          Also make sure to turn off this option:



          curl_setopt($ch, CURLOPT_VERBOSE, 0); 


          Or else it will still print everything to screen.






          share|improve this answer























          • 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















          15














          Also make sure to turn off this option:



          curl_setopt($ch, CURLOPT_VERBOSE, 0); 


          Or else it will still print everything to screen.






          share|improve this answer























          • 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













          15












          15








          15







          Also make sure to turn off this option:



          curl_setopt($ch, CURLOPT_VERBOSE, 0); 


          Or else it will still print everything to screen.






          share|improve this answer













          Also make sure to turn off this option:



          curl_setopt($ch, CURLOPT_VERBOSE, 0); 


          Or else it will still print everything to screen.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          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

















          • 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

















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          27

          Top Tejano songwriter Luis Silva dead of heart attack at 64

          Category:Rhetoric