I have the following code
$user;
if (isset($_POST['submitLogin']))
{
$GLOBALS['user'] = logIn();
// location1
}
function logIn()
{
$user = new User("my username", "my email");
return $user;
}
// location2
Then I want to display that information like this:
echo $GLOBALS['user']->__get('username');
but it only works in location1. I have worked around this by using a global array and passing the data from the User instance to that global array, but this defeats the purpose of using classes. If you could just give me a hint or put me on the right track I'd be very thankful.