我想學習Codeigniter。我已經在CI站點上的教程之後構建了一個簡單的MVC。這是我的控制器......Codeigniter鏈接到樣式表
<?php
class Pages extends CI_Controller {
public function view($page = 'home'){
if(!file_exists(APPPATH.'/views/pages/'.$page.'.php')){
show_404();
}
$data['title'] = ucfirst($page);
$this->load->view('templates/header', $data);
$this->load->view('pages/'.$page, $data);
$this->load->view('templates/footer', $data);
}
}
這裏是頭部模板...
<html>
<head>
<title><?php echo $title ?> - WurkWithUs</title>
<link rel="stylesheet" href="http://localhost/ci/CodeIgniter_2.1.2/css/bootstrap.css" type="text/css" media="screen"/>
<link rel="stylesheet" href="http://localhost/ci/CodeIgniter_2.1.2/css/custom.css" type="text/css" media="screen"/>
</head>
<body>
<h1>Wurk With Us</h1>
的樣式表,當我使用絕對路徑類似上面的工作。但是,如果我嘗試使用類似...
<link rel="stylesheet" href="<?= base_url()?>css/bootstrap.css" type="text/css" media="screen"/>
我得到一個空白頁。當我「查看頁面源代碼」我的風格,線條看起來像......
<link rel="stylesheet" href="
我曾試圖按照建議here和我即文件停止在的「href =」行被解析相同的結果。
我在做什麼錯?有沒有更好的方式來加載我的樣式表?
是的,只是想出來感謝你的幫助。我只是寫我自己的答案。阿羅哈 – noel