note 83948 added to function.curl-setopt

From: Date: Thu, 19 Jun 2008 21:19:16 +0000
Subject: note 83948 added to function.curl-setopt
Groups: php.notes 
Request: Send a blank email to php-notes+get-140601@lists.php.net to get a copy of this message
Someone posted this under tmpfile (http://us3.php.net/manual/en/function.tmpfile.php#69419), and I thought it was particularly useful: By the way, this function is really useful for libcurl's CURLOPT_PUT feature if what you're trying to PUT is a string. For example: /* Create a cURL handle. */ $ch = curl_init(); /* Prepare the data for HTTP PUT. */ $putString = "Hello, world!"; $putData = tmpfile(); fwrite($putData, $putString); fseek($putData, 0); /* Set cURL options. */ curl_setopt($ch, CURLOPT_URL, "http://www.example.com"); curl_setopt($ch, CURLOPT_PUT, true); curl_setopt($ch, CURLOPT_INFILE, $putData); curl_setopt($ch, CURLOPT_INFILESIZE, strlen($putString)); /* ... (other curl options) ... */ /* Execute the PUT and clean up */ $result = curl_exec($ch); fclose($putData); curl_close($ch); ---- Server IP: 208.69.120.35 Probable Submitter: 67.137.26.114 ---- Manual Page -- http://www.php.net/manual/en/function.curl-setopt.php Edit -- https://master.php.net/note/edit/83948 Del: integrated -- https://master.php.net/note/delete/83948/integrated Del: useless -- https://master.php.net/note/delete/83948/useless Del: bad code -- https://master.php.net/note/delete/83948/bad+code Del: spam -- https://master.php.net/note/delete/83948/spam Del: non-english -- https://master.php.net/note/delete/83948/non-english Del: in docs -- https://master.php.net/note/delete/83948/in+docs Del: other reasons-- https://master.php.net/note/delete/83948 Reject -- https://master.php.net/note/reject/83948 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#140601) next »