實(shí)例化model出錯(cuò)了
我是按照老師所說的做的。
在function user 中寫入了這些
<?php namespace?Home\Controller; use?Think\Controller; class?IndexController?extends?Controller?{ ????public?function?index(){ //省略了 ????} ????public?function?user() ????{ ????//其實(shí)新版的url應(yīng)該這么寫:http://www.thinkphptest.com/index.php/Home/Index/user ????$user=new?M("user"); ????$dateuser=$user->select(); ????dump($dateuser); ????$this->display(); ????} }
配置文件是這樣的:
<?php return?array( //'配置項(xiàng)'=>'配置值' 'URL_MODEL'=>2, 'SHOW_PAGE_TRACE'=>true, 'DB_TYPE'=>'mysql', 'DB_HOST'=>'localhost', 'DB_NAME'=>'think', 'DB_USER'=>'root', 'DB_PWD'=>'', 'DB_PREFIX'=>'th_', );
數(shù)據(jù)庫沒問題。
錯(cuò)誤信息是這樣的:
Class 'Home\Controller\M' not found
說是錯(cuò)誤信息就在實(shí)例化M那一行。
我翻過thinkphp3.2手冊,沒有找到相應(yīng)的答案。
環(huán)境:wamp2.5
版本:thinkphp3.2.3
我感覺應(yīng)該是命名空間問題,但是不知道怎么解決。求老師指導(dǎo)
2017-06-03
添加use think\Model
2015-07-16
我在user模型中這樣寫,可以運(yùn)行 thinkphp:3.2
<?php
namespace Home\Model;
use Think\Model;
/**
?*
?* @author Administrator
?* ? ? ? ?
?*/
class StudentModel extends Model{
public function showmsg(){
return "ok";
}
}
?>