CI_Config::__construct PHP Method

__construct() public method

Sets the $config data from the primary config.php file as a class variable.
public __construct ( ) : void
return void
    public function __construct()
    {
        $this->config =& get_config();
        // Set the base_url automatically if none was provided
        if (empty($this->config['base_url'])) {
            if (isset($_SERVER['SERVER_ADDR'])) {
                if (strpos($_SERVER['SERVER_ADDR'], ':') !== FALSE) {
                    $server_addr = '[' . $_SERVER['SERVER_ADDR'] . ']';
                } else {
                    $server_addr = $_SERVER['SERVER_ADDR'];
                }
                $base_url = (is_https() ? 'https' : 'http') . '://' . $server_addr . substr($_SERVER['SCRIPT_NAME'], 0, strpos($_SERVER['SCRIPT_NAME'], basename($_SERVER['SCRIPT_FILENAME'])));
            } else {
                $base_url = 'http://localhost/';
            }
            $this->set_item('base_url', $base_url);
        }
        log_message('info', 'Config Class Initialized');
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Constructor
  *
  * @access  public
  * @return  void
  */
 function __construct()
 {
     parent::__construct();
     $this->config_path = APPPATH . 'config/config' . EXT;
     $this->database_path = APPPATH . 'config/database' . EXT;
     $this->autoload_path = APPPATH . 'config/autoload' . EXT;
 }
All Usage Examples Of CI_Config::__construct