TP5控制器怎么调用模型方法?

浏览:12140 发布日期:2018/01/09 分类:ThinkPHP5专区 关键字: 控制器 TP5 模型 技术
模型:
<?php
name app\index\model;
use think\Model;
class TypeModel extends Model{

public function getdata(){

return '测试模型';
}
}
?>
控制器:
<?php
namespace app\index\controller;
use app\index\model\Type;
class Index extends \think\Controller
{

public function index()
{
$model = new Type;
echo $model->getdata();
}

}
结果:
页面错误!请稍后再试~
最佳答案
评论( 相关
后面还有条评论,点击查看>>