I was using curl
from shell scripts and was setting -s
option to make to make it silent
How to set this option in php curl?
http://php.net/manual/en/ref.curl.php
In recent versions of php, CURLOPT_MUTE
has (probably) been deprecated. Any attempt of using curl_setopt()
to set CURLOPT_MUTE
will give you a warning like this:
PHP Notice: Use of undefined constant CURLOPT_MUTE - assumed 'CURLOPT_MUTE' in ....
If you wish to silence the curl output, use the following instead:
<?php
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
?>
And then,
<?php
$curl_output=curl_exec($ch);
?>
The output of the curl operation will be stored as a string in $curl_output
while the operation remains totally silent.
You want to set the CURLOPT_MUTE setting when initializing the connection:
curl_setopt($curl_resource, CURLOPT_MUTE, 1);
This post is pretty old, but for future people looking for this answer, you need to use these two options in the current version of php5-curl:
<?php
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, false);
?>
The first option returns the raw response from curl_exec() so it can be assigned to a variable. The second option prevents curl_exec() from printing the response.
Looks like CURLOPT_MUTE
has been deprecated in recent versions of php.
I'm using PHP 5.3.6 and I'm getting Use of undefined constant CURL_MUTE - assumed 'CURL_MUTE'
whenever I try to set this option.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With