Skip to content

Instantly share code, notes, and snippets.

@p4ulypops
Created November 29, 2013 20:12
Show Gist options
  • Save p4ulypops/7711308 to your computer and use it in GitHub Desktop.
Save p4ulypops/7711308 to your computer and use it in GitHub Desktop.
<?
/*
*
*
* ----- Please note, my syntax is constantly evolving as I type this out
* ----- This really is a 10% done thing, in it's conception.
* ----- By the time you're reading this, i've probably changed
* ----- around the code a bit, but it should give you a general
*- ---- idea
*
* ---- Contribute here:
* ---- https://www.facebook.com/groups/191073427720886/permalink/229848117176750/
*
*/
// [object:user]Contains everything we need to do to get information about our site's users[/object]
class User {
// [explain]Store the user's information[/explain]
var $details;
// [explain]What happens when we create this *object*[/explain]
function __CONSTRUCT() {
$this->details = array('name' => 'Paul', 'level' => 'Awesome'); // [explain]Set the default stuff[/explain]
}
// [explain]Set this *object* to [var]id[/var][/explain] I could put some database logic here
function grabUser($id) {
if ($id == "1") {
$this->setDetails("Paul", "Awesome");
}elseif($id == "2") {
$this->setDetails("John", "OKayish");
}else{
$this->setDetails("Some Loser", "Rubbish");
}
}
// [explain]Make /this/ *object*'s with a [var]name[/var] and [var]level[/var]
function setDetails($name, $level) {
$this->details = array("name" => $name, "level" => $level);
}
// [explain]Return an *array* with the current /this/ 's information
function returnUser() {
return $this->details;
}
}
// [explain:1][auto][/explain]
$id = "2";
// [explain]Our user *Ob
$objUser = new User;
// [explain:1]Make [array]details[/array] and set it as [object]objUser[/object]'s [function]returnUser[/function][/explain]
$details = $objUser->returnUser();
//[explain:0]Display a welcome message with {details} [/explain]
echo "Hello ".$details['name']." - You are ".$details['level'];
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment