From the demo below you can probably see what I am trying to do, the construct method works but the test method does not work, gives error Fatal error: Call to a member function get() on a non-object
Can someone show me how to make something like this work?
<?PHP
//user.class.php file
class User
{
public $pic_url;
function __construct($session)
{
if($session->get('auto_id') != ''){
$this->pic_url = $session->get('pic_url');
}else{
return false;
}
}
function test($session)
{
return $this->pic_url = $session->get('pic_url');
}
}
$user = new user($session);
//this works
echo $user->pic_url;
//this one does not work
echo $user->test();
?>