managing curl output in php

前端 未结 2 1456
臣服心动
臣服心动 2020-11-28 08:02

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(         


        
相关标签:
2条回答
  • 2020-11-28 08:16

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

    0 讨论(0)
  • 2020-11-28 08:23

    Also make sure to turn off this option:

    curl_setopt($ch, CURLOPT_VERBOSE, 0);       
    

    Or else it will still print everything to screen.

    0 讨论(0)
提交回复
热议问题