1 use views
2. send
ci views
views maybe html or head or footer
\application\views
二、how to create views
files/view/ > XXX.php > html code
example:
<html> <h1> wooooo </h1> <p> >hehe </p> </html>
三、how to use views
$this -> load-> view('view filename');one example:
class Hello extends CI_Controller { function sayhello($name){ echo $name.'hello world'; } function show(){ $this->load->view('testview.php'); } }http://localhost/index.php/hello/show
multiple example:
class Hello extends CI_Controller { function sayhello($name){ echo $name.'hello world'; } function show(){ $this->load->view('testview.php'); $this->load->view('testview2.php'); } }
四、how to send varible to views
動態array傳送給views
example:
class Hello extends CI_Controller { function sayhello($name){ echo $name.'hello world'; } function show(){ $name = "roshiko"; $count = "1"; $arr = array('a' => 'a', 'b' => 'b'); $data = array('v_name' => $name, 'v_count' => $count, 'v_array'=> $arr); //can use foreach to read $this->load->view('testview.php', $data); $this->load->view('testview2.php'); } }
沒有留言:
張貼留言