Created
October 10, 2012 06:45
-
-
Save Wuvist/3863552 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 DummyClass | |
{ | |
public $msg; | |
} | |
$obj = new DummyClass(); | |
$obj->msg = "Hello World"; | |
echo $obj->msg.PHP_EOL; | |
class DummyClass3 | |
{ | |
private $_msg; | |
public function getMsg() | |
{ | |
return str_replace(" ", "", $this->_msg); | |
} | |
public function setMsg($msg) | |
{ | |
$this->_msg = $msg; | |
} | |
public function __get($key) | |
{ | |
$getter = 'get'.ucfirst($key); | |
return $this->$getter(); | |
} | |
public function __set($key, $val) | |
{ | |
$setter = 'set'.ucfirst($key); | |
$this->$setter($val); | |
} | |
} | |
$obj = new DummyClass3(); | |
$obj->msg = "Hello World"; | |
echo $obj->msg.PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment