note 14433 added to function.virtual.php
| From: | s dot dan at free dot fr | Date: | Tue, 31 Jul 2001 12:43:38 +0000 |
| Subject: | note 14433 added to function.virtual.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-16096@lists.php.net to get a copy of this message | ||
Another way of passing arguments:
If you have some CGI programs that depend on some libraries where you can't change the source
code (in my case an online payment library), you can pass the arguments by changing some environment
variables.
Of course the CGI program has to get the GET/POST variables in the usual manner.
It simulates, more or less, a direct call from the server to a CGI program:
// preparing the arguments passed to this PHP page
$QSTRING = $QUERY_STRING;
// pay attention to the maximum length of the QUERY string.
while (list ($header, $value) = each ($HTTP_POST_VARS)){
if (empty($QSTRING))
$QSTRING = $header.'='.$value;
else
$QSTRING = $QSTRING.'&'.$header.'='.$value;
}
putenv('REQUEST_METHOD=GET');
putenv('QUERY_STRING='.$QSTRING);
unset($return_array);
exec('my_CGI', $return_array, $return_val);
Now you can parse the output of 'my_CGI' in return_array.
http://www.php.net/manual/en/function.virtual.php