php - How to set public variable dynamically when a class instance is created -
when initialize new class instance want set public variable based on current url.
how go setting public variable dynamically when class instance created available without having call function.
class configurator{ static public $active = true; public $current_url="<current_url here>" }
use constructor :
class configurator{ static public $active = true; public $current_url="<current_url here>" public function __construct($url) { $this->current_url = $url; } }
you can call object :
$configurator = new configurator($your_url);
Comments
Post a Comment