作者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
1F:推 arzbar:问题还是一样 就算每支都require 但是资料还是没办法带到 03/20 04:00
2F:→ arzbar:别的user 身上... 03/20 04:01
3F:→ arzbar:只能靠 file or db 去传递现在值 03/20 04:01
4F:推 aquarianboy:推作坏事 :) 03/20 08:52