關於 PHP, Linux, Open Source 及個人生活記載的網誌。
RSS icon
  • 用 .htaccess 定義 PHP 變數

    Posted on October 4th, 2006 Sam Tang No comments

    一般上如果有一些 Global 的變數,會在一個 PHP 檔案內儲存,其實用 .htaccess 也可以做到相同的效果,而所定義的變不但可給 PHP 存取,在 CGI 內也可以使用。例如在 .htaccess 內加入以下內容:

    SetEnv DB_USER mysqluser
    SetEnv DB_PASS mysqlpass

    以上的變數分別是 $_SERVER['DB_USER'] 及 $_SERVER['DB_PASS'],它們的值是 mysqluser 及 mysqlpass。


    Leave a reply

    *
    To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
    Click to hear an audio file of the anti-spam word