How to write detailed information to a file?

I am using CURL in my php script and I want to write information from CURLOPT_VERBOSE to a file. I tried CURLOPT_STDERR but no luck. It still prints everything in the CMD window. I'm not sure if the parameter is in curl_setopt ($ ch, CURLOPT_STDERR, $ errFileHandle); must be a file handler or file name (both do not work).

+4
source share
1 answer

Work on a Unix-based OS? Use the following command on the command line to run the script. Using Windows, use the command in Cygwin.

php yourPhp.php > yourFile.txt 

Or you can just run it in verbose mode using a file descriptor

 <?PHP $verbosPath = __DIR__.DIRECTORY_SEPARATOR.'verboseOut.txt'; echo "Saving verbose output to: $verbosPath\n"; $handle=curl_init('http://www.google.com/'); curl_setopt($handle, CURLOPT_VERBOSE, true); curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); curl_setopt($handle, CURLOPT_STDERR,$f = fopen($verbosPath, "w+")); curl_exec($handle); fclose($f); ?> 
+4
source

All Articles