我需要發送和獲取類到另一個類像在MVC方法的變量:如何發送和提取
class Demo {
private $vars = array();
function set($var , $data) {
$this->vars[$var] = $data;
}
function request() {
extract($this->vars);
var_dump($vars);
}
}
,我想用上面的類成這樣:
class Test extends foo {
function __construct(){
$this->demo = new Demo();
}
function register(){
$user = Load::model('user');//Now User Is An Object
$this->demo->set('user',"$user");//This Is Error
$this->demo->request();
}
Catchable fatal error: Object of class user could not be converted to string in
是結束'}'在類'Test'實際的代碼? – sjsam