86  Other Useful CGI Environment Variables


  • Other Useful CGI Environment Variables

    CGI 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

    其它 相關資訊:

  • 本文由 boy Jheng 於 酷Go夢工坊 - 部落街 2007-10-15(20:28:37)星期一 發表。

  • 【p.86 / 回上一頁/ 下一篇/ 頁首/ 頁尾 /關於 /連結


    [首頁] [活動中心] [佈告欄] [留言板] [部落街] [聊天室] [討論區] [文學殿] [搜尋] [測試區] [註冊] [紀實] [登入] 部落街文章大集合
    www.kugo.idv.tw ICON

    上一頁▲頁首