Tuesday, November 13, 2007

PHP CGI Weirdity

I don't know why anyone would ever want to programmatically call the CGI version of PHP, but there's a slight weirdness you'll have to deal with. If you call it with just the normal CGI environment variables, PHP will complain that it was compiled with "--enable-force-cgi-redirect," and that it needs some extra stuff.

Here's that stuff:
1. REDIRECT_STATUS. I just set this to 200, and it seemed to work. Pretty sure that refers to the HTTP status, but I really haven't researched it at all.
2. PATH_TRANSLATED. This is just the location on disk of the php script to run.

Setting these two seemed to work, but (just for kicks) I also set REDIRECT_URL = SCRIPT_URL = REDIRECT_SCRIPT_URL = the URL (minus the server name, ie "/dir/script.php".)

No comments: