Other Useful CGI Environment VariablesCGI scripts have access to 20 or so environment variables, such as QUERY_STRING and CONTENT_LENGTH mentioned on the main page. Here's the complete list at NCSA. A few others you may find handy: REQUEST_METHOD The HTTP method this script was called with. Generally ”GET”, ”POST”, or ”HEAD”. HTTP_REFERER The URL of the form that was submitted. This isn't always set, so don't rely on it. Don't go invading people's privacy with it, neither. PATH_INFO Extra ”path” information. It's possible to pass extra info to your script in the URL, after the filename of the CGI script. For example, calling the URL http://www.myhost.com/mypath/myscript.cgi/path/info/here will set PATH_INFO to ”/path/info/here”. Commonly used for path-like data, but you can use it for anything. SERVER_NAME Your Web server's hostname or IP address (at least for this request). SERVER_PORT Your Web server's port (at least for this request). SCRIPT_NAME The path part of the URL that points to the script being executed. It should include the leading slash, but certain older Web servers leave the slash out. You can guarantee the leading slash with this line of Perl: $ENV{'SCRIPT_NAME'}=~ s#^/?#/# ; So the URL of the script that's being executed is, in Perl, ”http://$ENV{'SERVER_NAME'}:$ENV{'SERVER_PORT'}$ENV{'SCRIPT_NAME'}” The complete URL the script was invoked with may also have PATH_INFO and QUERY_STRING at the end. 更多關於:Other Useful CGI Environment Variables 其它 相關資訊: |