Home  >  Article  >  php教程  >  php使用session二维数组实例

php使用session二维数组实例

WBOY
WBOYOriginal
2016-06-06 20:18:41968browse

这篇文章主要介绍了php使用session二维数组的用法,实例形式讲述了session中对于二维数组的运用技巧,非常具有实用价值,需要的朋友可以参考下

本文实例讲述了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