Created
February 22, 2009 04:05
-
-
Save kodi/68322 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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