Well what i want to do is , fetch a value from a database and asign it to a session name something like this
$_SESSION[$fetch[0]['name']]=some_value;
i dont know if im able to do that but it'll be quite usefull to 开发者_如何学运维me.
Short answer is yes you can do that, but i would advise you to set a static value such as:
$_SESSION["name"] = $fetch[0]['name'];
and then you can just use $_SESSION["name"]
to get the value.
everything written in the php is classed as hard code, you should be aware that setting dynamic content as array keys are usually unreliable.
Why not? As long as you can still use the value that is returned by $fetch[0]['name']
...
精彩评论