Filippo oretti
Filippo oretti

Reputation: 49843

Codeigniter / PHP - declare class private var

hi i have this simple class for example:

class Asd{
 private $_url = $this->config->config['url']; 
}

but it doesn't get the config param any clue on how to do that?

How do i call a config param in private var ?

Upvotes: 0

Views: 349

Answers (2)

som
som

Reputation: 4656

You can do like this :

class Asd {
   private $_url;
   public function __construct() {
      $CI =& get_instance();
      $this->_url = $CI->config->config['url']; 
   } 
}

You can't declare class property as you want.

Upvotes: 3

Variables can be assigned only constructor!

class Asd{
 private $_url;
 public function __construct() {
      $CI =& get_instance();
      $this->_url = $CI->config->config['url'];  
   }  
}

Below is not possible

 class Asd{
     private $_url='www.so.com';
     public function __construct() {
          $CI =& get_instance();
          $this->_url = $CI->config->config['url'];  
       }  
    }

Upvotes: 1

Related Questions