thinkPHP控制层的接口写法(简洁)

<?php
//	http://localhost/tp3/index.php/Home/Index/index 是这个路径
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function index(){
        $this->show('<p>欢迎使用 <b>index页面</b>!</p>');
    }
    
    public function add(){
        $Tables= M("tables");           //M方法自动造模型
		$at =$Tables->where('ages=20')->select();
		$this->show(json_encode($at,JSON_UNESCAPED_UNICODE));
		//json_encode是转换成json字符串       第二个参数是解决中文乱码问题
    }
}

猜你喜欢

转载自blog.csdn.net/qq_41619567/article/details/84762778