Amin Amin - 8 months ago 16
PHP Question

How to send and extract class

I need to send and get Class into another class like a variable in MVC method :

class Demo {

private $vars = array();

function set($var , $data) {
$this->vars[$var] = $data;

function request() {





And i want to use above class into this :

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

Catchable fatal error: Object of class user could not be converted to string in


remove the quotes

$this->demo->set('user', $user);

And don't forget to create your variable in your class scope

class Test extends foo {
    public $demo;

should do the trick