Passing a variable to .php with curl

software development

#1

Hello,
I couldn’t find how to pass a variable to a script using curl.
I mean, this:

<?php $ch = curl_init(); $timeout = 5; // set to zero for no timeout curl_setopt ($ch, CURLOPT_URL, 'http://example.com'); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $file_contents = curl_exec($ch); curl_close($ch); // display file echo $file_contents; ?>

would echo a plain url, but if the url is something like http://example.com/test.php?var1=value how do you pass var1?


#2

it’s part of the url, so i would expect it to work with CURLOPT_URL set to ‘http://example.com/test.php?var1=value

track7 - my dream-hosted site


#3

dammit was it so obvious… excuse me while i go back in hiding