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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -