[請益] CodeIgniter 中的base_url的使用問題

看板PHP作者 (raison detre)時間13年前 (2012/12/25 10:41), 編輯推噓1(107)
留言8則, 3人參與, 最新討論串1/1
小弟為 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
抱歉忘了說,我的版本是2.1.3
12/25 10:42, 1F

12/25 10:48, , 2F
我config.php中的$config['base_url']也有設定
12/25 10:48, 2F

12/25 10:48, , 3F
請問這個是對應到base_url()的嗎
12/25 10:48, 3F

12/25 14:19, , 4F
不是對應到那個 你應該是要呼叫url helper網站有使用方式
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
我是都用原來的html sample檔,再load->view這個頁面
05/30 09:54, 7F

05/30 09:56, , 8F
回錯 ><
05/30 09:56, 8F
文章代碼(AID): #1GsH9Esx (PHP)
文章代碼(AID): #1GsH9Esx (PHP)