1、在window下,下载框架http://www.thinkphp.cn/down.html
2、解压文件,放置在www目录
3、文件地址http://localhost/thinkphp/public/
4、打开调试窗口application->config.php 'app_debug' => true
5、模板加载use think\Controller; 配置继承Index extends Controller $this->fetch();
6、url书写方式 {:url('控制器名字/方法名字')} eg:{:url('index/test')} 引入use think\Request;
7、获取参数https://www.kancloud.cn/manual/thinkphp5/118042 Request::instance() -> param('title')
8、数据库连接use
think\Db;
插入数据
$db = Db::name('user');
$res = $db->insert([
'email' => 'imooc_02',
'password' => md5('imooc_02'),
'username' => 'imooc_02',
]);
查询
$result = Db::query("select * from dsj where user_name='$user' and user_pass='$pass' ");
更新
Db::table('think_user')->where('id', 1)->update(['name' => 'thinkphp']);
删除
Db::execute("delete from user where email ='thinkphp'");
cookie设置
cookie(‘name’,'value',30*60);
cookie获取
cookie(‘name值’)
cookie删除
cookie('name',null)
书写ajax步骤
<script src="/js/jquery.min.js"></script>
<script>
$('p').click(function(){
$.ajax({
url:"{:url('my/my')}",
method:'post',
data:{
user:'user'
},
success:function(res){
console.log(res);
}
})
})
</script>