All pastes #506704 Raw Edit

Untitled

public php v1 · immutable
·published 2007-05-24 04:06 UTC
rendered paste body
<?phpclass user {function get_user($id) {	// Assume DB Connection exists, etc.		// Global Keyword lets us override the normal variable scope.	global $db;		$db->get_results("SELECT * FROM user where id = '$id'");		// Parse results...	// I'm not going to write this part.	// It's self explanatory.		// Assign vars to an array inside of the class.		// Simple:	$this->name = $user->name;	$this->email = $user->email;		// Complex... probably better.	$this->vars = array(				'name' => $user->name;				'email' => $user->email;			)	}}// Call the class.$user = new user;// Get User$user->get_user(1);// What's the User Name? (Simpleecho $user->name;// Complexecho $user->vars['name'];?>