gpt4 book ai didi

php 和 session : how get an associative array from a session variable?

转载 作者:行者123 更新时间:2023-12-04 05:25:10 26 4
gpt4 key购买 nike

这个问题在这里已经有了答案:




8年前关闭。




Possible Duplicate:
Able to see a variable in print_r()'s output, but not sure how to access it in code



我需要与连接的用户在现有网站上工作:
<?php session_start();
print_r($_SESSION); ?>

此代码输出:
Array([%http_user%] => Array
(
[profile_id] => 72
[username] => john
[session_id] => 4ek79umrrpael7vvb4ls3diaq4
)

[registration_invite_code] =>

)

这就是我需要的。它试图让“约翰”进入我的 $username变量:

知道如何吗?

我试过:
$_SESSION[0]

$_SESSION["%http_user%"]

$_SESSION->username

没办法。

任何方式如何检索这个用户名?

谢谢

最佳答案

$variable = $_SESSION['%http_user%']['username'];

关于php 和 session : how get an associative array from a session variable?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13279794/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com