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

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -