Testing CGI scripts with QUERY_STRING, in PHP
When developing a CGI script and before putting on the production server, you need to test it; to catch runtime errors, but more generally, to check if you get the expected result depending on the parameters.
To emulate a GET request without setting up a Web server, the easiest method is probably to set the QUERY_STRING and REQUEST_METHOD environment variables and run the script through its interpreter, e.g. REQUEST_METHOD="GET" QUERY_STRING="foo=bar" php4 filename.php.
Well, this used to work till recently – I assumed it broke with PHP 4.3 release; nowadays, the php4 executable comes in two flavours: the CLI and the CGI SAPI; the former is designed to be use out of Web context, so isn’t much relevant to this case.