精華區beta PHP 關於我們 聯絡資訊
小弟為 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
ireullin:抱歉忘了說,我的版本是2.1.3 12/25 10:42
ireullin:我config.php中的$config['base_url']也有設定 12/25 10:48
ireullin:請問這個是對應到base_url()的嗎 12/25 10:48
kaiyuegg:不是對應到那個 你應該是要呼叫url helper網站有使用方式 12/25 14:19
kaiyuegg:http://ppt.cc/Rt3z 12/25 14:19
ireullin:謝謝你^^ 12/25 14:24