출력(output) Sample

<?php
/**
 * Output Class
 *
 * Created on 2011. 11. 16.
 * @author 불의회상 <hoksi2k@hanmail.net>
 * @package library
 * @subpackage controllers
 * @version 1.0
 */
class Output_lib extends CI_Controller {
	function __construct() {
		parent::__construct();
	}
	
	function index() {
		// 최종 출력 문자열  설정
		$output = "Output test";
		$this->output->set_output($output);
		
		// $this->output->set_output()을 한 번 이상 호출 하면 마지막에 설정 된 문자열로 대체됨
		$output  = "<html>\n<head>\n\t<meta http-equiv='content-type' content='text/html; charset=UTF-8'/>\n";
		$output .= "\t<title>Output 라이브러리 샘플</title>\n</head>\n";
		$this->output->set_output($output);

		// 출력클래스로 전송된 데이터 가져오기
		$data['output'] = $this->output->get_output();
		
		// CI의 뷰는 출력클래스를 통해서 전달됨
		$this->load->view('output_lib_sample', $data);
		
		// 출력 문자열에 데이터 추가
		$output = "<tr>\n  <td>\$this->output->append_output()</td>\n";
		$output .= "  <td>\$this->output->append_output() 을 통한 출력</td>\n</tr>\n";
		$this->output->append_output($output);

		$output = "</table>\n</body>\n</html>";
		$this->output->append_output($output);

		// JSON 데이터, JPEG's, XML 등을 손쉽게 제공하기 위해서 마임타입을 (mime-type)을 설정
		// config/mimes.php 확인
		$this->output->set_content_type('text/html');

		// output 데이터에 서버헤더(server headers)를 설정
		// php header() 함수를 대신하여 사용
		$this->output->set_header("HTTP/1.0 200 OK");
		$this->output->set_header("HTTP/1.1 200 OK");
		$this->output->set_header('Last-Modified: '.gmdate('D, d M Y H:i:s', time()).' GMT');
		$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate");
		$this->output->set_header("Cache-Control: post-check=0, pre-check=0");
		$this->output->set_header("Pragma: no-cache");
	}
}
<?php $this->load->view('inc/header')?>


<table class="tablesorter" border="0" cellpadding="0" cellspacing="1">
<thead>
<tr>
  <th style="width:20%;">구분</th>
  <th>결과</th>
</tr>
</thead>
<tr>
  <td>$this->output->get_output()</td>
  <td><xmp><?php echo $output?></xmp></td>
</tr>

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

© Copyright by hoksi(Page rendered in 0.0069 seconds)