CodeBlockTest

Created Friday 13 May 2016




 OOP example 


nickname = "$thenickname";
	}
	
	public function setRealname($therealname) {
		$this->_realname = "$therealname";
	}
	
	public function getNickname() {
		return $this->nickname;
	}
	
	public function saymynickname() {
		echo "
They call me $this->nickname"; } public function saymyrealname() { echo "DISCLAMER!! DONT TELL ANYONE!!! BUT...
"; echo ".. my realname is $this->_realname
"; } } echo "here is some class stuff
"; $cap = new being(); /* -- NO, BAD FORM $cap->nickname = "Cap!"; */ $cap->setNickname("Cappy cap"); /* THIS IS NAUGHTY ALSO !! echo "The nickname of the new being is $cap->nickname"; */ $cap->saymynickname(); $currentnickname = $cap->getNickname(); echo "
Yes, thats right. My nickname is $currentnickname
"; /* OKAY, now with realname... */ /* $cap->_realname = "Will Rogers"; DONT RUN THIS, IT BREAKS. AS IT SHOULD */ $cap->setRealname("Steve Rogers"); echo "
but secretly....
"; $cap->saymyrealname(); echo "
now you know my secret"; ?>