[請益] CodeIgniter 中的base_url的使用問題
小弟為 CodeIgniter 的新手
以下兩個範例是我遇到的問題
不管我使用 base_url 或是 site_url 都會遭遇到一樣的狀況
是否是我使用的方式有誤
example 1
main.php:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Main extends CI_Controller {
public function index() {echo base_url();}
}
?>
執行結果:
瀏覽器收到完全空白的文件
example 2
main.php:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Main extends CI_Controller {
public function index() {$this->load->view('main.view');}
}
?>
main.view:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="../css/style.css" type="text/css" />
<title></title>
</head>
<body>
<p id="ID_P1">
<?php echo base_url();?>
</p>
</body>
</html>
執行結果:
base_url() 後面的東西就完全出不來了
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="../css/style.css" type="text/css" />
<title></title>
</head>
<body>
<p id="ID_P1">
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 219.84.255.117
→
12/25 10:42, , 1F
12/25 10:42, 1F
→
12/25 10:48, , 2F
12/25 10:48, 2F
→
12/25 10:48, , 3F
12/25 10:48, 3F
推
12/25 14:19, , 4F
12/25 14:19, 4F
→
12/25 14:19, , 5F
12/25 14:19, 5F
→
12/25 14:24, , 6F
12/25 14:24, 6F
→
05/30 09:54, , 7F
05/30 09:54, 7F
→
05/30 09:56, , 8F
05/30 09:56, 8F
PHP 近期熱門文章
PTT數位生活區 即時熱門文章