01 2021 档案

摘要:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>购物车实例</title> <link rel="stylesheet" href="style.css" > </head> <body> <div id=" 阅读全文
posted @ 2021-01-22 14:41 孙旋 阅读(55) 评论(0) 推荐(0)
摘要:获取器 获取器的作用是在获取数据的字段值后自动进行处理,例如,我们需要对状态值进行转换,可以使用: class User extends Model { public function getStatusAttr($value) { $status = [-1=>'删除',0=>'禁用',1=>'正 阅读全文
posted @ 2021-01-14 15:56 孙旋 阅读(312) 评论(0) 推荐(0)
摘要:时间戳 系统支持自动写入创建和更新的时间戳字段,有两种方式配置支持。 第一种方式,是在数据库配置文件中添加全局设置: // 开启自动写入时间戳字段 'auto_timestamp' => true, 第二种是直接在单独的模型类里面设置: protected $autoWriteTimestamp = 阅读全文
posted @ 2021-01-13 14:41 孙旋 阅读(361) 评论(0) 推荐(0)
摘要:如何自定义路由: 路由定义采用\think\Route类,通常是在应用的路由配置文件application/route.php进行注册 use think\Route;// 注册路由到index模块的News控制器的read操作 Route::rule('new/:id','index/News/r 阅读全文
posted @ 2021-01-13 10:49 孙旋 阅读(186) 评论(0) 推荐(0)
摘要:模型会自动对应数据表,模型类的命名规则是除去表前缀的数据表名称,采用驼峰法命名,并且首字母大写 设置数据表 namespace app\index\model; use think\Model; class User extends Model{ // 设置当前模型对应的完整数据表名称 protec 阅读全文
posted @ 2021-01-13 10:47 孙旋 阅读(106) 评论(0) 推荐(0)
摘要:第一种方式:全局配置方式 在项目配置文件中添加相关的布局模板配置,就可以简单实现模板布局功能,比较适用于全站使用相同布局的情况,需要在config.php中配置开启layout_on 参数(默认不开启),config.php中原本没有就只需要添加即可,并且设置布局入口文件名layout_name(默 阅读全文
posted @ 2021-01-12 16:40 孙旋 阅读(161) 评论(0) 推荐(0)
摘要:验证码使用: 首先使用Composer安装think-captcha扩展包: composer require topthink/think-captcha=1.* 模版内验证码的显示 <div>{:captcha_img()}</div> <div><img src="{:captcha_src( 阅读全文
posted @ 2021-01-11 15:52 孙旋 阅读(125) 评论(0) 推荐(0)
摘要:use Illuminate\Support\Facades\Route; Route::get('/', function () { return view('welcome'); }); //任意方式请求 // Route::any('/login',function(){ // return 阅读全文
posted @ 2021-01-11 13:58 孙旋 阅读(95) 评论(0) 推荐(0)
摘要:use think\Route; //路由规则 // Route::rule('/a','admin/index/index'); // Route::get('/productlist/:id','/admin/index/productlist');//带参数 // Route::any('/p 阅读全文
posted @ 2021-01-11 13:57 孙旋 阅读(112) 评论(0) 推荐(0)
摘要:<?php //使用session //设置session // session_start(); // $_SESSION['a'] = 'admin'; //设置cookie,如果有cookie,说明用户已经登陆或者cookie在过期时间内,可以进行页面跳转,直接跳转到首页 if($_COOKI 阅读全文
posted @ 2021-01-09 11:25 孙旋 阅读(60) 评论(0) 推荐(0)
摘要:<?php header("content-type:text/html;charset=utf-8"); // $a = 1; // echo $GLOBALS; // echo $_SERVER; // echo $_ENV; // var_dump($_REQUEST); var_dump($ 阅读全文
posted @ 2021-01-09 11:22 孙旋 阅读(59) 评论(0) 推荐(0)
摘要:<?php header("content-type:text/html;charset=utf-8"); //数组 定义 $arr = array('a','b'); $arr = ['a','b']; //数值数组 $arr = [1,2]; //关联数组 $arr = [ 'name'=>'张 阅读全文
posted @ 2021-01-08 11:58 孙旋 阅读(61) 评论(0) 推荐(0)
摘要:<?php header("content-type:text/html;charset=utf-8"); //变量的作用域 //php中,全局变量无法在定义的函数中直接使用 $i = 1; function con($i){ // echo $i; //错误,$iunderfind //如果想使用 阅读全文
posted @ 2021-01-08 10:53 孙旋 阅读(69) 评论(0) 推荐(0)
摘要:<?php header("content-type:text/html;charset=utf-8"); //设置编码 /* 整数类型: 1.整数是一个没有小数的数字。 2.整数可以是正数或负数 3.整型可以用三种格式来指定:十进制, 十六进制( 以 0x 为前缀)或八进制(前缀为 0) 进制之间 阅读全文
posted @ 2021-01-06 09:34 孙旋 阅读(86) 评论(0) 推荐(0)
摘要:<?php //使用session //设置session // session_start(); // $_SESSION['a'] = 'admin'; //设置cookie,如果有cookie,说明用户已经登陆或者cookie在过期时间内,可以进行页面跳转,直接跳转到首页 if($_COOKI 阅读全文
posted @ 2021-01-05 14:28 孙旋 阅读(86) 评论(0) 推荐(0)
摘要://模拟登录 // $admin = 0; // if($admin != 10){ // //页面跳转 // $this->success('登录失败','login/index'); // $this->error('登录失败'); // $this->redirect('login/index 阅读全文
posted @ 2021-01-05 14:25 孙旋 阅读(170) 评论(0) 推荐(0)
摘要:/** * 使用助手函数不需要引入request类 * */ //判断请求类型 // Request::instance()->isPost(); // request()->isPost(); //判断变量是否设置 // Request::instance()->has('变量名','提交方式') 阅读全文
posted @ 2021-01-05 08:36 孙旋 阅读(140) 评论(0) 推荐(0)
摘要:恢复内容开始 null 恢复内容结束 阅读全文
posted @ 2021-01-05 08:32 孙旋 阅读(70) 评论(0) 推荐(0)