檢視 (View) 是把處理完的資料輸出
新增動態資料到 View
<?php class Blog extends CI_Controller { function index() { $data['todo_list'] = array('Clean House','Call Mom','Run Errands'); $data['title'] = "My Real Title"; $data['heading'] = "My Real Heading"; $this->load->view('blogview', $data); } } ?>
開啟檢視檔(view file)
# welcome_message.php <html> <head> <title><?php echo $title;?></title> </head> <body> <h1><?php echo $heading;?></h1> <h3>My Todo List</h3> <ul> <?php foreach ($todo_list as $item):?> <li><?php echo $item;?></li> <?php endforeach;?> </ul> </body> </html>
Last updated 4 years ago