0
我今天開始使用codeIgniter,並且正在遵循phpacademy的初學者教程。 現在我有一個奇怪的問題。我得到了以下非常簡單的控制器:代碼點火器不會從我的控制器加載函數
<?php if (! defined('BASEPATH')) exit("No direct script access allowed");
class Site extends CI_Controller {
public function index()
{
}
public function home()
{
$this->load->view("view_home", $data);
}
function about()
{
$data['title'] = "About!";
$this->load->view("view_about", $data);
}
function test()
{
echo "test";
}
}
它總是加載索引函數罰款。當我測試它時,它會回顯任何我想要的回聲。但是當我調用其他函數時,什麼都不會發生。
我沒有設置我.htacces呢,但是當我訪問以下地址: 本地主機:8899/index.php文件/網站/家
不加載主頁功能。其他功能(「關於」和「測試」)也一樣;
當我打電話的功能之一(「約」,「家」和「測試」),從指數()函數中它並調用它應該如何:
class Site extends CI_Controller {
public function index()
{
$this->home();
}
public function home()
{
$this->load->view("view_home", $data);
}
我不是很確定這裏出了什麼問題。希望有人能指引我朝着正確的方向發展!
我的路線:
<?php if (! defined('BASEPATH')) exit("No direct script access allowed");
$route['default_controller'] = "site";
$route['404_override'] = '';
你在你的config.php中設置了base_url嗎? 'localhost:8899/index.php'和'localhost:8899/index.php/site/index'是否適用於加載索引方法?發佈routes.php文件的內容也是值得的。 – Jeemusu
是的。 'localhost:8899/index.php/site/index'也加載我的索引方法就好了 – Kevinvhengst
哦,我還沒有設置我的'BASE_URL'。我讀CI會自動檢測te基地網址自2.0 – Kevinvhengst