關于訪問的URL 不正確
我用的是這個http://localhost/test/index.php?m=Index&a=Index 發現用其實需要寫一個action 方法才可以, 也就是說在thinkPHP3.2.6 里面是用的http://localhost/test/index.php?m=Index&a=action 才能訪問, 代碼如下:?
$module?=?isset($_GET['m'])?$_GET['m']:'Index';
$action?=?isset($_GET['a'])?$_GET['a']:'Index';
$mooc=new?$module();
$mooc->action();
class?index
{
function?__construct()
{
echo?'調用了Index?控制器'?;
}
function?index()
{
echo?'我是index?控制器的index方法';
}
function?test()
{
echo?'我是index?控制器的index方法';
}
function?action()
{
echo?'我是index?控制器的action?方法';
}
}
//?開啟調試模式?建議開發階段開啟?部署階段注釋或者設為false
define('APP_DEBUG',True);
exit?;
2017-04-05
$module?=?isset($_GET['m'])?$_GET['m']:'Index';
$action?=?isset($_GET['a'])?$_GET['a']:'Index';
?
$mooc=new?$module();
$mooc->(你這個action前邊少了$符號吧)action();
少了的話,就是只會調用action()方法,它不會根據傳入的參數進行變化。