开发小记

开发过程的学习小记 以防老年痴呆哈哈哈哈

1.think5的获取session

后端$token != Session::get('__token__') 获取token

前端tp5的token获取 {$Request.token}

2.session验证原理
页面访问 后台会生成session 保存在服务器端 该session由时间和其他加密成一个token传给页面
提交的时候ajax带上token 后端接收这个token跟服务器的token对比 
验证是否一样 
生成时间-现在时间==时间差 跟我设置的session的过期时间对比
两个一起验证是否过期


3.checkbox的一些东西

重置 checkbox样式 -webkit-appearance: inherit;
checkbox状态监控  remember_me:$("#remember-me").prop('checked')?1:0,


4.css布局

对于那些类似名片类的布局 建议使用dispaly:inline-block

对每一个子元素设置display:inline-block 

然后可通过vertical-align:middle设置每一子元素相互之间上下居中对齐


5.使用transform 进行上下左右居中对齐的时候 在3d情况下 会相差半个像素 导致图像模糊

建议使用transform2d配合 left top

6使用

html_entity_decode():编译富文本编辑器的内容 示例{php echo html_entity_decode($articledetail['assortintroduce'])}


7.p标签内的img元素高度超出问题解决overflow:auto;  zoom:1;


8.white-space: nowrap;让div伸出页面 而不然页面整个左右移动

9.插件封装的一种方式

;(function($){
var Slider = function(ele,option){
var self = this;
self._init()
}
Slider.prototype = {

}
Slider.prototype._init = function(){

}
$.fn.slider = function(option){
return new Slider(this,option)
}
})(jQuery)


10.iphone上滚动条的反弹效果-webkit-overflow-scrolling : touch; 解决滚动条滚动


11.cookie

cookie保存在客户端 可用于记住密码之类的操作 

session是保存在服务端 表单过期时间

接入第三方登录是让用户方便快捷地使用已有账号登录你的网站或应用程序,提高用户体验的一种方式。本文将介绍如何使用 PHP 实现微信公众号第三方登录。 1. 获取微信授权 首先,需要获取微信用户的授权。具体步骤如下: 1)引导用户打开微信授权页面: ```php $appid = 'your_appid'; $redirect_uri = urlencode('http://yourdomain.com/callback.php'); $scope = 'snsapi_userinfo'; $url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=$appid&redirect_uri=$redirect_uri&response_type=code&scope=$scope&state=STATE#wechat_redirect"; header("Location: $url"); ``` 其中,`$appid` 是你的微信公众号的 AppID,`$redirect_uri` 是授权后回调的 URL,`$scope` 是授权作用域,可以是 `snsapi_base` 或 `snsapi_userinfo`,`$state` 是自定义参数,用于防止 CSRF 攻击。 2)获取授权码: 用户同意授权后,会重定向到 `$redirect_uri` 指定的 URL,带上授权码 `code` 和 `state` 参数。 ```php $code = $_GET['code']; $state = $_GET['state']; ``` 3)获取 access_token 和 openid: 使用授权码 `code` 获取 `access_token` 和 `openid`。 ```php $access_token_url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=$appid&secret=$secret&code=$code&grant_type=authorization_code"; $response = file_get_contents($access_token_url); $result = json_decode($response, true); $access_token = $result['access_token']; $openid = $result['openid']; ``` 其中,`$secret` 是你的微信公众号的 AppSecret。 2. 获取用户信息 获取到 `access_token` 和 `openid` 后,可以使用以下代码获取用户信息: ```php $userinfo_url = "https://api.weixin.qq.com/sns/userinfo?access_token=$access_token&openid=$openid&lang=zh_CN"; $response = file_get_contents($userinfo_url); $userinfo = json_decode($response, true); ``` 其中,`$userinfo` 包含用户的昵称、头像等信息。 3. 将用户信息保存到数据库 最后,将获取到的用户信息保存到数据库中,以便下次使用时快速登录。 ```php // 连接数据库 $con = mysqli_connect('localhost', 'username', 'password', 'database'); mysqli_set_charset($con, "utf8"); // 查询用户是否已存在 $sql = "SELECT * FROM users WHERE openid='$openid'"; $result = mysqli_query($con, $sql); if (mysqli_num_rows($result) == 0) { // 用户不存在,插入新用户信息 $nickname = mysqli_real_escape_string($con, $userinfo['nickname']); $headimgurl = mysqli_real_escape_string($con, $userinfo['headimgurl']); $sql = "INSERT INTO users (openid, nickname, headimgurl) VALUES ('$openid', '$nickname', '$headimgurl')"; mysqli_query($con, $sql); } // 保存用户登录状态 $_SESSION['openid'] = $openid; ``` 以上就是使用 PHP 实现微信公众号第三方登录的步骤。需要注意的是,为了确保安全性,应该对用户输入的数据进行过滤和验证,防止 SQL 注入和 XSS 攻击等。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值