How do I get a session Variable out of a class in PHP
How do I call the variables out of the clas开发者_StackOverflow中文版s?
You don't need to do anything with a class to access session variables in php.
Just use the superglobal $_SESSION
Example:
print_r($_SESSION); // View all your session variables
echo $_SESSION['a_session_variable']; //Access a specific variable
If by session you mean $_SESSION, you should be able to access this from anywhere.
If by session, you mean the member variabless of the class, that's a bit trickier.
class SomeClass()
{
$name;
}
$someClass = new SomeClass();
echo $someClass->name;
精彩评论