extract后即可直接使用变量,不需要修改php.inihttp://www.php.net/manual/en/function.extract.phpExtract provides an invaluable way to get around the possibility of the PHP directive register_globals being off or on. If you're used to register_globals being on, and you're worried that new PHP 4.2.0 implementations will mess up existing code (because it now defaults to off), try using this:if (!empty($_GET)) { extract($_GET); } else if (!empty($HTTP_GET_VARS)) { extract($HTTP_GET_VARS); }if (!empty($_POST)) { extract($_POST); } else if (!empty($HTTP_POST_VARS)) { extract($HTTP_POST_VARS); }That's from PHPMyAdmin (to give proper credit), and the same thing would probably be useful elsewhere. Thanks,Steve
2.楼上的老兄说的对, 如果是post来提交的你可以用$HTTP_POST_VARS["变量名"]来取得。
如果是get来提交的你可以用$HTTP_GET_VARS["变量名"]来取得
如果是session来提交的你可以用$HTTP_SESSION_VARS["变量名"]来取得。
可php.ini在什么地方?我有两台机器,一台Win2000 Server,一台Red Hat Linux 7.1,我找了很多地方都没有找到!
但有如下问题末解决:
如果链接如下:
http://x.x.x.x/x.php?name='ok'
如何来获取name变量的值!!!
winnt
在c:\windows下
或是在c:\winnt下。下一个答案:
$_ENV -- 包含系统环境变量
$_GET -- 包含查询字符串中的变量,以及提交方法为GET的表单中的变量
$_POST -- 包含提交方式为POST的表单中的变量
$_COOKIE -- 包含所有cookie变量
$_SERVER -- 包含服务器变量,例如HTTP_USER_AGENT
$_REQUEST -- 包含$_GET、$_POST和$_COOKIE的全部内容
$_SESSION -- 包含所有已注册的session变量
在接收页用这个就可以了得到那个值了。
directive register_globals being off or on. If you're used to
register_globals being on, and you're worried that new PHP 4.2.0
implementations will mess up existing code (because it now defaults to
off), try using this:if (!empty($_GET)) {
extract($_GET);
} else if (!empty($HTTP_GET_VARS)) {
extract($HTTP_GET_VARS);
}if (!empty($_POST)) {
extract($_POST);
} else if (!empty($HTTP_POST_VARS)) {
extract($HTTP_POST_VARS);
}That's from PHPMyAdmin (to give proper credit), and the same thing would
probably be useful elsewhere. Thanks,Steve