Skip to content

Instantly share code, notes, and snippets.

@kodi
Created February 22, 2009 04:05
Show Gist options
  • Save kodi/68322 to your computer and use it in GitHub Desktop.
Save kodi/68322 to your computer and use it in GitHub Desktop.
<?php
class User{
function setUsername($username){
$this->internalUsername=$username;
}
function getUsername(){
if(!isset($this->internalUsername)){
$this->internalUsername='Not defined yet';
}
return $this->internalUsername;
}
}
// in real life code above will be in separate file
$u=new User();
echo "username: ".$u->getUsername();
$u->setUsername('Rich');
echo "<br />username: ".$u->getUsername();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment