0
lain posted
Object of class could not be converted to string in PHP
i made PHP Class , doing some experiment with class concept . creating dynamic array which give field name and try to access property with other function in PHP , and getting Catchable fatal error
class obj {
public $id='';
public $name='';
public $desc='';
public $user='';
public $dynamic = array("id","name","desc","user");
public function process(){
foreach($this->dynamic as $value){
echo $this->$value;
}
}
}
$ob = new obj();
$ob->user=new user();
$ob->process();
getting Catchable fatal error ::
Object of class could not be converted to string in PHP