Skip to content

Instantly share code, notes, and snippets.

@qwqcode
Created October 7, 2017 13:30
Show Gist options
  • Save qwqcode/6e7764fd88e23eba5efcb09526280b20 to your computer and use it in GitHub Desktop.
Save qwqcode/6e7764fd88e23eba5efcb09526280b20 to your computer and use it in GitHub Desktop.
Object Test
class Ha {
function __construct() {
// 1. Look there
$action = new Action();
$action->setMsg("你好世界");
$this->handleActionObj($action, "Hello World");
echo $action->getMsg();
}
function handleActionObj(Action $actionObj, $msg) {
$actionObj->setMsg($msg);
}
}
class Action {
private $msg = "";
public function setMsg($msg) {
$this->msg = $msg;
}
public function getMsg() {
return $this->msg;
}
}
// 1
new Ha();
echo "<br/>";
// 2
(function () {
// 2. Look there
$a = "你好世界";
$b = $a;
$b = "Hello World";
echo $a;
})();
// 执行结果:
// Hello World
// 你好世界
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment