Heim  >  Artikel  >  Backend-Entwicklung  >  $_SESSION['expanded'][$_GET['expand']] = true;什么意思解决办法

$_SESSION['expanded'][$_GET['expand']] = true;什么意思解决办法

WBOY
WBOYOriginal
2016-06-13 11:58:581348Durchsuche

$_SESSION['expanded'][$_GET['expand']] = true;什么意思
$_SESSION['expanded'][$_GET['expand']] = true;什么意思
这个写法好怪。
------解决方案--------------------
$_GET['expand'] 是获取以get方式传递的参数值。
$_SESSION['expanded'][ ] 是一个二维数组。

例如$_GET['expand'] 的值是abc
那么
$_SESSION['expanded'][$_GET['expand']] = true;
等于
$_SESSION['expanded']['abc'] = true;

很怪吗?
最后$_SESSION的值是array('expanded'=>array('abc'=>true));
------解决方案--------------------
print_r($_SESSION)
就知道数组长什么样子
------解决方案--------------------

<br />$a = $_GET['expand']; //取出$_GET['expand']中的值<br />$b = 'expanded'; //$b赋值<br />$_SESSION[b][a] = true; //设置session值<br />


无非就是单词长点!
------解决方案--------------------
<br />$a = $_GET['expand']; //取出$_GET['expand']中的值<br />$b = 'expanded'; //$b赋值<br />$_SESSION[$b][$a] = true; //设置session值<br />


------解决方案--------------------
 不奇怪吧,就是一个session二维数组。。
------解决方案--------------------
是数组问题
$_SESSION['expanded']=$abc
$_GET['expand']=2
换下来就是
$abc[2]=true
这是典型的数组写法了

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn