URI(uri) Sample

<?php
/**
 * Uri Class
 *
 * Created on 2011. 11. 16.
 * @author 불의회상 <hoksi2k@hanmail.net>
 * @package library
 * @subpackage controllers
 * @version 1.0
 */
class Uri_lib extends CI_Controller {
	function __construct() {
		parent::__construct();
	}
	
	function index() {
		// 특정 세그먼트를 추출
		$data['segment'] = $this->uri->segment(3);
		// 세그먼트가 없을때 리턴될 기본값을 지정
		$data['default_segment'] = $this->uri->segment(20, '1');
		
		// 배열을 입력받아 URI 문자열을 생성
		$data['assoc_to_uri'] = $this->uri->assoc_to_uri(array('product' => 'shoes', 'size' => 'large', 'color' => 'red'));
		
		$this->load->view('uri_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" colspan="2">URI 관련</th>
</tr>
</thead>
<thead>
<tr>
  <th style="text-align:center" width="20%">Method</th>
  <th width="80%">결과</th>
</tr>
</thead>
<tr>
	<td>$this->uri->uri_string()</td>
	<td><?=$this->uri->uri_string()?></td>
</tr>
<tr>
	<td>$this->uri->total_segments()</td>
	<td><?=$this->uri->total_segments()?></td>
</tr>
<tr>
	<td>$this->uri->segment(3)</td>
	<td><?=$segment?></td>
</tr>
<tr>
	<td>$this->uri->segment(20, '1')</td>
	<td><?=$default_segment?></td>
</tr>
<tr>
	<td>$this->uri->slash_segment(5)</td>
	<td><?=$this->uri->slash_segment(5)?></td>
</tr>
<tr>
	<td>$this->uri->slash_segment(5, 'leading')</td>
	<td><?=$this->uri->slash_segment(5, 'leading')?></td>
</tr>
<tr>
	<td>$this->uri->slash_segment(5, 'both')</td>
	<td><?=$this->uri->slash_segment(5, 'both')?></td>
</tr>
<tr>
	<td>$this->uri->segment_array()</td>
	<td><xmp><?php print_r($this->uri->segment_array())?></xmp></td>
</tr>
<tr>
	<td>$this->uri->uri_to_assoc()</td>
	<td><xmp><?php print_r($this->uri->uri_to_assoc())?></xmp></td>
</tr>
<tr>
	<td>$this->uri->uri_to_assoc(5)</td>
	<td><xmp><?php print_r($this->uri->uri_to_assoc(5))?></xmp></td>
</tr>
<tr>
	<td>$this->uri->assoc_to_uri()</td>
	<td><xmp><?=$assoc_to_uri?></xmp></td>
</tr>
<thead>
<tr>
  <th style="text-align:center" colspan="2">재 라우팅(re-routed) URI 관련</th>
</tr>
</thead>
<tr>
	<td>$this->uri->ruri_string()</td>
	<td><?=$this->uri->ruri_string()?></td>
</tr>
<tr>
	<td>$this->uri->total_rsegments()</td>
	<td><?=$this->uri->total_rsegments()?></td>
</tr>
<tr>
	<td>$this->uri->rsegment(3)</td>
	<td><?=$this->uri->rsegment(3)?></td>
</tr>
<tr>
	<td>$this->uri->rsegment(20, '1')</td>
	<td><?=$this->uri->rsegment(20, '1')?></td>
</tr>
<tr>
	<td>$this->uri->slash_rsegment(5)</td>
	<td><?=$this->uri->slash_rsegment(5)?></td>
</tr>
<tr>
	<td>$this->uri->slash_rsegment(5, 'leading')</td>
	<td><?=$this->uri->slash_rsegment(5, 'leading')?></td>
</tr>
<tr>
	<td>$this->uri->slash_rsegment(5, 'both')</td>
	<td><?=$this->uri->slash_rsegment(5, 'both')?></td>
</tr>
<tr>
	<td>$this->uri->rsegment_array()</td>
	<td><xmp><?php print_r($this->uri->segment_array())?></xmp></td>
</tr>
<tr>
	<td>$this->uri->ruri_to_assoc()</td>
	<td><xmp><?php print_r($this->uri->uri_to_assoc())?></xmp></td>
</tr>
<tr>
	<td>$this->uri->ruri_to_assoc(5)</td>
	<td><xmp><?php print_r($this->uri->uri_to_assoc(5))?></xmp></td>
</tr>
</table>

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

© Copyright by hoksi(Page rendered in 0.0497 seconds)