2016-07-29 9 views
0

Ich mag mich so etwas wie diesecodeigniter Zugriffssteuerungsvariable in Config

<?php 
defined('BASEPATH') OR exit('No direct script access allowed'); 

/* 
|-------------------------------------------------------------------------- 
| Base Site URL 
|-------------------------------------------------------------------------- 
| 
| URL to your CodeIgniter root. Typically this will be your base URL, 
| WITH a trailing slash: 
| 
| http://example.com/ 
| 
| WARNING: You MUST set this value! 
| 
| If it is not set, then CodeIgniter will try guess the protocol and path 
| your installation, but due to security concerns the hostname will be set 
| to $_SERVER['SERVER_ADDR'] if available, or localhost otherwise. 
| The auto-detection mechanism exists only for convenience during 
| development and MUST NOT be used in production! 
| 
| If you need to allow multiple domains, remember that this file is still 
| a PHP script and you can easily do that on your own. 
| 
*/ 
echo $code; 
$config['base_url'] = 'http://localhost/'; 

Jetzt in meiner Heimat Controller

<?php 
defined('BASEPATH') OR exit('No direct script access allowed'); 
class Home extends CI_Controller{ 
public function index(){ 

$x=1; 
if($x==1){ 
$this->config->set_item('code', 'somevalue1'); 
}else if($x==2){ 
$this->config->set_item('code', 'somevalue2'); 
} 
} 
} 

nun tun, wie ich Wert zugreifen kann von zu Hause Datei von Controller-Anwendung /config/config.php

+0

Auch Ihr Projekt base_url sollte '$ config [ 'base_url'] =‚http: // localhost/yourproject/'; ' – user4419336

Antwort

0

In Config.php

So legen Wert

$this->config->set_item('code', 'My Value'); 

auf den Wert zuzugreifen

echo $this->config->item('code'); 
+0

hast du das überprüft? –

+0

ok wenn ich so etwas machen möchte dann – daulat

+0

$ config ['base_url'] = "http: // localhost /". $ Code; – daulat