
新建了一个项目 TP3.2.3
在model 下写了一个类
<?php
namespace Home\Model;
use Think\Model;
class OtherModel extends Model{
public function getApi(){
echo "api";
}
}
?>就这样 看了好多人说 把数据库配置上 我配置上就报错 没有 other 的这个表的错误 难道要写一个model 就要创建这样一个 名字的表么 告诉我下哈哈就是想访问这个 getApi 的方法 然后输出一个
在index控制器调用
<?php
namespace Home\Controller;
use Think\Controller;
use Home\Model\OtherModel;
class IndexController extends Controller {
public function index(){
$oModel = new OtherModel();
$oModel->getApi();
}
}新建的项目 config 什么都没有 最佳答案