var inside var in oop php -
im biginner in object oriented programming , learning object oriented php , have got bit confused including variable inside variable inside of class, like:
$div_content="some content"; $div = '<div>'.$div_content.'</div>';
but when trying this, error:
class someclass{ private $div_content ="some content"; public $div='<div>'.$div_content.'</div>'; function __construct(){ echo $this->div; } }
can 1 please me understand im doing wrong here? in advance.
function __construct(){ $this->div = '<div>'.$this->div_content.'</div>'; echo $this->div; }
you can define static values on declarations, use __construct() it
Comments
Post a Comment