时间:2021-07-01 10:21:17 帮助过:6人阅读
get("userid")) ; $i++)
{
$data[] = $redis->hgetall("user:".$i);
}
/* var_dump($data) 的结果如下:
array (size=3)
0 =>
array (size=0)
empty
1 =>
array (size=4)
'uid' => string '1' (length=1)
'username' => string 'jjj' (length=3)
'password' => string '123' (length=3)
'age' => string '20' (length=2)
2 =>
array (size=4)
'uid' => string '2' (length=1)
'username' => string 'lamp' (length=4)
'password' => string '123' (length=3)
'age' => string '20' (length=2)
*/
?>
user list
uid
username
age
html标签中使用php变量,提示:Undefined index: uid in /var/www//list.php
,list.php的具体代码如下:
get("userid")) ; $i++)
{
$data[] = $redis->hgetall("user:".$i);
}
/* var_dump($data) 的结果如下:
array (size=3)
0 =>
array (size=0)
empty
1 =>
array (size=4)
'uid' => string '1' (length=1)
'username' => string 'jjj' (length=3)
'password' => string '123' (length=3)
'age' => string '20' (length=2)
2 =>
array (size=4)
'uid' => string '2' (length=1)
'username' => string 'lamp' (length=4)
'password' => string '123' (length=3)
'age' => string '20' (length=2)
*/
?>
user list
uid
username
age
echo 前 isset 下不就可以了吗
你的数组第第一个子元素为空啊找不到uid
php很多时候,很需要注意的一点就是要做好容错机制