这是我第二次使用CodeIgniter,有一件事情不成功。从我的主页发送一个变量到我的标题。这是我的控制器:如何通过控制器发送页面到页面的变量
public function index()
{
$data['data'] = $this->BookModel->get_author();
$this->load->view('templates/header', $data);
$this->load->view('home/index');
$this->load->view('templates/footer', $data);
}
正如你看到的,它装载我header
,我index
和我footer
。
这是我的索引文件:
<?php
$title = "Books"; ?>
<div class="content">
<table>
...
,这是我的部首:
<html>
<head>
<meta charset="utf-8">
<title>Author plaza</title>
<link rel="stylesheet" type="text/css" href="<?php echo base_url('assets/css/style.css') ?>">
</head>
<body>
<div class="website">
<div class="header">
<h1 class="kopje"><?php echo $title; ?> </h1>
<img class="boekje" src="<?php echo base_url('assets/img/book.gif')?>">
</div>
可变需要$title
使用在我的header
echo
作为H1
打印。因为我知道这是正确的方式。但它不会工作。
有人可以帮助我吗?
Yeas Thanx。这对我有用! –