Consider this php script test.script, and the call: php test.script 4444 <?php $card = $argv[ 1 ]; echo "$card\n"; require_once 'HTTP/Request.php'; $req = new HTTP_Request( 'http://www.???.com?cc_number=4444&exp_date=0612' ); $req -> sendRequest(); ?> (Note that I've omitted the actual URL I'm testing with, as that isn't a factor). The echo command correctly displays 4444 to my screen, but my goal here is to use the passed parameter in the HTTP_Reqest line, as in: $req = new HTTP_Request( 'http://www.???.com?cc_number=$card&exp_date=0612' ); But using the "$card" syntax exactly how I have it in the line above does not work, when the hardcoded "4444" above does work properly. There must be something I do not yet understand about how to use variables in php, but I cannot find syntax examples anywhere. Can anyone direct me as to how I can utilize an input parameter as a variable in the HTTP call above? Any help is much appreciated.
Its your use of quotes; if you use doouble quotes variables will be expanded, in single they will not. consider this. <?php $card = 4444; print 'hello $card'; print "hello $card"; ?> PHP: OUTPUT: hello $card hello 4444 You can get away with it by concatenating the value; $req = new HTTP_Request( 'http://www.???.com?cc_number='.$card.'&exp_date=0612' ); PHP: