在函数里注册SESSION变量
$_SESSION['NAME'] = $VAR
$_SESSION['NAME'] = $VAR
解决方案 »
- form 提交不过去
- smarty学习专区
- 哪位高手会的?请指教!!!
- 求助怎么将#cccccc这个颜色格式转换为(255,255,0)等 这样的格式啊?有什么思路 ? 在网上搜索的方法说16转换为10进制也不行啊(不对啊)
- 正则题,求解答
- 新手关于调试时的问题。
- javascript 传递php变量
- php中有str_replace函数吗?如果有,怎么用?谢谢
- 请问哪有邮件列表的程序啊,收费的也可以
- 关于apache 2.4.6 KeepAlive的设置
- 关于一个全文匹配替换解决办法:查找全文中的<tag|a|link... src="src.ext" >中的src.ext并替换为处理后的数据,但tag不包含input,src不
- 先问个THINKPHP关于SAVE的问题
function getxx(&$sessionvar){
$sessionvar="ggg";
}
$f=getxx($Session["tt"]);
$HTTP_SESSION_VAR["USER"]
在类,函数中。
<?php
function Sadd(){
$temp1="qqq";
$temp2="www";
$temp3="eee";
session_register("session_temp1");
session_register("session_temp2");
session_register("session_temp3");
$session_temp1=$temp1;
$session_temp2=$temp2;
$session_temp3=$temp3;}
?>
外面访问是这样的
echo $session_temp1;
<?php
function Sadd(){
$temp1="qqq";
$temp2="www";
$temp3="eee";
session_register("session_temp1");
session_register("session_temp2");
session_register("session_temp3");
$session_temp1=$temp1;
$session_temp2=$temp2;
$session_temp3=$temp3;
//--------------------------------------- 加上这个吧
$GLOBALS['session_temp1'] = $temp1;
$GLOBALS['session_temp2'] = $temp2;
$GLOBALS['session_temp3'] = $temp3;
//--------------------------------------- 加上这个吧
}
?>
外面访问是这样的
echo $session_temp1;
这样应该没有问题了
function Sadd(){
$temp1="qqq";
$temp2="www";
$temp3="eee";
session_register("session_temp1");
session_register("session_temp2");
session_register("session_temp3");////应该这样
$session_temp1=$temp1;//$_SESSION["session_temp1"]=$temp1;
$session_temp2=$temp2;//$_SESSION["session_temp2"]=$temp2;
$session_temp3=$temp3;//$_SESSION["session_temp3"]=$temp3;}
?>
ps:$_SESSION本身就是superglobal,在任何地方都不需要global
//--------------------------------------- 加上这个吧
$GLOBALS['session_temp1'] = $temp1;
$GLOBALS['session_temp2'] = $temp2;
$GLOBALS['session_temp3'] = $temp3;
//--------------------------------------- 加上这个吧
是有必要的。
就是一个简单的东东,从PHP4.2开始就有了$_SESSION[] 超级全局数组,
什么$GLOBALS都不用了,程序如下:<?php
session_start();
function Sadd()
{
$temp1="qqq";
$_SESSION["session_temp1"]=$temp1;}
Sadd();
echo $_SESSION["session_temp1"];
?>