뷰 업그레이드
문서
변경된 사항
업그레이드 가이드
먼저 모든 뷰를 app/Views 폴더로 이동하십시오.
- 뷰를 로드하는 모든 스크립트에서 뷰 로드 구문을 변경하십시오:
$this->load->view('directory_name/file_name')에서return view('directory_name/file_name');으로$content = $this->load->view('file', $data, TRUE);에서$content = view('file', $data);으로
(선택 사항) 뷰의 echo 구문을
<?php echo $title; ?>에서<?= $title ?>으로 변경할 수 있습니다.defined('BASEPATH') OR exit('No direct script access allowed');줄이 있으면 제거하십시오.
코드 예제
CodeIgniter 버전 3.x
경로: application/views:
<html>
<head>
<title><?php echo html_escape($title); ?></title>
</head>
<body>
<h1><?php echo html_escape($heading); ?></h1>
<h3>My Todo List</h3>
<ul>
<?php foreach ($todo_list as $item): ?>
<li><?php echo html_escape($item); ?></li>
<?php endforeach; ?>
</ul>
</body>
</html>
CodeIgniter 버전 4.x
경로: app/Views:
<html>
<head>
<title><?= esc($title) ?></title>
</head>
<body>
<h1><?= esc($heading) ?></h1>
<h3>My Todo List</h3>
<ul>
<?php foreach ($todo_list as $item): ?>
<li><?= esc($item) ?></li>
<?php endforeach ?>
</ul>
</body>
</html>