php为什么使用构造函数后session赋值就失效了,只要去掉构造函数就恢复正常,请高手帮忙下
session_start();switch($_SESSION["test"]){case1:$contentStr=1;$_SESSION["test"]=$_SES...
session_start();
switch ($_SESSION["test"]){
case 1:
$contentStr = 1;
$_SESSION["test"]=$_SESSION["test"]+1;
break;
case 2:
$contentStr = 2;
$_SESSION["test"]=$_SESSION["test"]+1;
break;
case 3:
$contentStr = 3;
$_SESSION["test"]=$_SESSION["test"]+1;
break;
default:
$_SESSION["test"] = NULL;
$contentStr = 0;
$_SESSION["test"]=$_SESSION["test"]+1;
break;
}
echo $contentStr."-";
class atest{
function __construct($val){
$this -> test = $val;
}
function a(){
echo $this -> test;
}
function __destruct() {
$this -> test = NULL;
}
}
$test = new atest($contentStr);
$test -> a(); 展开
switch ($_SESSION["test"]){
case 1:
$contentStr = 1;
$_SESSION["test"]=$_SESSION["test"]+1;
break;
case 2:
$contentStr = 2;
$_SESSION["test"]=$_SESSION["test"]+1;
break;
case 3:
$contentStr = 3;
$_SESSION["test"]=$_SESSION["test"]+1;
break;
default:
$_SESSION["test"] = NULL;
$contentStr = 0;
$_SESSION["test"]=$_SESSION["test"]+1;
break;
}
echo $contentStr."-";
class atest{
function __construct($val){
$this -> test = $val;
}
function a(){
echo $this -> test;
}
function __destruct() {
$this -> test = NULL;
}
}
$test = new atest($contentStr);
$test -> a(); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询