網站開發基本教學
  • Introduction
  • 基本元素
  • Nginx (伺服器)
    • Config 基本配置
    • Regular Expression 正規化
  • Codeigniter (程式語言框架)
    • Config
    • Controller
    • View
    • Model
      • Question
    • Helper
    • MVC
  • MySQL
Powered by GitBook
On this page

Was this helpful?

  1. Codeigniter (程式語言框架)

View

檢視 (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>
PreviousControllerNextModel

Last updated 5 years ago

Was this helpful?