Created
October 7, 2017 13:30
-
-
Save qwqcode/6e7764fd88e23eba5efcb09526280b20 to your computer and use it in GitHub Desktop.
Object Test
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
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