Home  >  Article  >  Backend Development  >  php使用session二维数组实例_PHP

php使用session二维数组实例_PHP

WBOY
WBOYOriginal
2016-05-31 19:28:181066browse

本文实例讲述了php使用session二维数组的用法。分享给大家供大家参考。具体如下:

最普通的用法:一个变量名

代码如下:

$_SESSION['user'] = 0;
echo $_SESSION['user'];


使用数组:

代码如下:

$_SESSION['user']['a'] = 1;
$_SESSION['user']['b'] = 2;
echo $_SESSION['user']['a'];
echo $_SESSION['user']['b'];


这样的好处是可以分组。
 
如可以使用:

代码如下:

$_SESSION['admin']['a'] = 11;
$_SESSION['admin']['b'] = 22;

希望本文所述对大家的PHP程序设计有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn