2016-07-29 2 views
1

나는 3로드 사용자 지정 설정 파일 CodeIgniter는 3

$this->config->load('test') 

test.php 파일 내용을 다음과 application/config 폴더에 있습니다 CodeIgniter의에서 사용자 지정 설정을로드하려합니다.

<?php 

$config['item_test']='sample config item'; 

나는 다음과 같은 오류 구성 파일 test.php이 존재하지 않는

을 얻을 것이다.

CodeIgniter의 버전 : 3.1.0

답변

3

응용 프로그램/config 폴더에 새 파일 이름 test.php를 작성합니다.

  • 애플리케이션/구성/test.php

    <?php 
        $config['gender'] = array('Male', 'Female'); 
    ?> 
    
  • 컨트롤러/filename.php

    class Stackoverflow extends CI_Controller{ 
         function __construct() { 
          parent::__construct(); 
    
          $this->config->load('test'); //loading of config file 
         } 
    
         function index(){ 
    
          print_r($this->config->item('gender')); //Calling of config element.  
        } 
    } 
    
  • 출력

    어레이 ([0] => 남성 [1 ] => 여성)