환경설정클래스(config) Sample

<?php
/**
 * Config Class
 *
 * Created on 2011. 11. 16.
 * @author 불의회상 <hoksi2k@hanmail.net>
 * @package library
 * @subpackage controllers
 * @version 1.0
 */
class Config_lib extends CI_Controller {
	function __construct() {
		parent::__construct();
	}
	
	function index() {
		// 설정 파일은 'application/config/*.php' 로 저장
		// 직접 만든 설정파일을 로드 함
		// Sample로 예시된 설정파일 : application/config/blog.php
		//
		$this->config->load('blog');
		
		// blog.php 내용
		// $config['item_name'] = 'Blog';
		
		// 설정에서 item_name 값을 가져옴
		$data['load_item_name'] = $this->config->item('item_name');
		
		// 동적으로 item_name 값 변경
		$this->config->set_item('item_name', 'item_value');
		$data['set_item_name'] = $this->config->item('item_name');
		
		$this->load->view('config_lib_sample', $data);
	}
}
<?php $this->load->view('inc/header')?>

<table class="tablesorter" border="0" cellpadding="0" cellspacing="1">
<thead>
<tr>
  <th style="text-align:center" width="20%">환경변수</th>
  <th width="80%">값</th>
</tr>
</thead>
<tr>
	<td>item_name(Default)</td>
	<td><?php echo $load_item_name?></td>
</tr>
<tr>
	<td>item_name(동적 변경)</td>
	<td><?php echo $set_item_name?></td>
</tr>
<thead>
<tr>
  <th style="text-align:center" width="20%">헬퍼 함수</th>
  <th width="80%">값</th>
</tr>
</thead>
<tr>
	<td>$this->config->site_url()</td>
	<td><?php echo $this->config->site_url()?></td>
</tr>
<tr>
	<td>$this->config->base_url()</td>
	<td><?php echo $this->config->base_url()?></td>
</tr>
<tr>
	<td>$this->config->system_url()</td>
	<td><?php echo $this->config->system_url()?></td>
</tr>
</table>

<?php $this->load->view('inc/footer')?>

© Copyright by hoksi(Page rendered in 0.0066 seconds)