I've been looking everywhere for a solution of this but I can't find one...
Basically what I did was created a class named USER.
public class USER{
private static $USER = array();
public function __construct($U='')
{
// if $U is not entered (=='') then set $U to MY USER ID ($_COOKIE['user'])
// do a mysql query by the ID (ala $U) and store the results to self::$USER
}
public function ID()
{
return self::$USER['id'];
}
}
This is the code I am running...
I do a user profile page that shows different properties of the USER from the database: USERNAME(),ID(),PHONE(),EMAIL(), etc. etc.
// creates an instance of a different user (other than myself)
$PROFILE = new USER($ID); // $ID: 26 will retrieve USERNAME: Test
// create an instance of user class for myself using the cookie holding my id
$ME = new USER($_COOKIE['user']) // $_COOKIE['user']: 01 will retrieve USERNAME: Monster
echo($PROFILE->USERNAME()); // displays Monster
echo($PROFILE->ID()); // displays 01
Any idea what I am doing wrong? I would assume that $PROFILE->USERNAME() would display Test and $ME->USERNAME() would show monster.