Skip to content

Instantly share code, notes, and snippets.

@Wuvist
Created October 10, 2012 06:45
Show Gist options
  • Save Wuvist/3863552 to your computer and use it in GitHub Desktop.
Save Wuvist/3863552 to your computer and use it in GitHub Desktop.
<?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