作者JoeHorn (獅子男)
看板PHP
標題Re: [請益] 伺服器變數
時間Thu Mar 20 01:44:42 2008
※ 引述《del680202 (飄落的櫻花)》之銘言:
: 請問PHP有沒有像ASP.NET一樣的伺服器全域變數
: 就是application[]這個 只有伺服器沒關就會存在的變數
: 目前有看到$_ENV 感覺好像是 但是不敢確定
: 推 alpe:還是去好好看一下 php.net 吧 $_SERVER $_COOKIE 03/19 22:33
: → del680202:$_SERVER 我瀏覽器關掉他就不見哩= =" 03/19 22:38
: → del680202:我是要存在SERVER上 所以我也不能用cookie 03/19 22:38
: 推 JoeHorn:您要存什麼? 不能用 define('blah', $blah); ? 03/19 23:49
: → del680202:我是希望這個變數給所有user共用 所以要存在伺服器上 03/19 23:55
: → del680202:define我記的是定義全域變數吧= =" 03/19 23:56
: → del680202:ASP的時候有application這個伺服器變數可以用 03/19 23:56
: → del680202:就是瀏覽器關掉 打開他仍會存在 因為是存在伺服器上 03/19 23:57
: 推 arzbar:php 沒有你要的東西 你要的 只能用DB來記錄 03/20 00:11
基本上,要硬幹也是可以的。
在
http://www.php.net/ini.core 可以看到這段:
auto_prepend_file string
Specifies the name of a file that is automatically parsed before the
main file. The file is included as if it was called with the require()
function, so include_path is used.
The special value none disables auto-prepending.
所以說....
只要我們放一個 /somewhere/something.php ,裡面寫上:
<?php
define('SERVER_BLAH', 'blah');
.....
?>
然後在 php.ini 裡面設定這行:
auto_prepend_file = "/somewhere/something.php"
如此一來, PHP 的核心要運作任何 PHP 檔案之前,
都會先用 require() 來呼叫 /somewhere/something.php 。 :p
--
來來來,大家來作壞事。 XD
--
ke◢ ★ ◣ro ta◢ ▼ ◣ma gi◢ Φ ◣ro ku◢ @ ◣lu ....... ◢
◆ ◣
◢> <◣ ◢ ∩ ∩ ◣ ◢◣ ◢◣ @ ≡ @ ◢
◎ ◎◣
█ █ █◢ ▼ ◣█ ██████ ████ █
◢ ◣█
◤◥
▼ ◤
◥ ◤◥██◤
◥ ◤◥
▲ ◤
◥ ◥
皿 ◤ ◥◥
/| ◤◤
ke▆ ★ ▆ro ta▆ ▼ ▆ma gi <◢◤> ro ku▆ @ ▆lu ◆
kero ▄ kero tama ▄ tama giro ▄ giro kulu ▄ kulu ▄ by[V]
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.116.37.9
推 arzbar:問題還是一樣 就算每支都require 但是資料還是沒辦法帶到 03/20 04:00
→ arzbar:別的user 身上... 03/20 04:01
→ arzbar:只能靠 file or db 去傳遞現在值 03/20 04:01
推 aquarianboy:推作壞事 :) 03/20 08:52