【发布时间】:2014-03-11 18:57:23
【问题描述】:
尝试学习 OO PHP,但我对某些事情感到困惑。在将 -> 链接在一起之前,我使用过框架来调用这些函数中的多个函数或变量。
ex. $variable = $this->query($stmt)->result()->name;
您将如何进行设置?
class test{
public $name;
public function __construct(){
$this->name = 'Jon'; // pretending that Jon is a db call result
}
public function change_name($n){
$this->name = $n;
}
public function get_name(){
return $this->name;
}
}
$i = new test();
我该怎么做?或者这完全不可能。
$i->change_name('george')->get_name; // as an example
【问题讨论】:
-
我认为可能有一个答案,但在谷歌搜索了几个小时后,我找不到我要找的东西。感谢您朝着正确的方向前进
标签: php