![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Function
王叨叨is
这个作者很懒,什么都没留下…
展开
-
PHP递归的三种方式
1、利用引用做参数PHP 的引用允许用两个变量来指向同一个内容,例如 KaTeX parse error: Expected 'EOF', got '&' at position 5: a = &̲b; 这意味着 $a 和 $b 指向了同一个变量。如下例子,因为 $data 使用了引用传递,所以数据会一直累加。function recursion(&$data = [], $i = 0){ if ($i < 10) { $data[] = $i;原创 2021-04-10 09:15:06 · 229 阅读 · 0 评论 -
PHP递归获取文件夹结构
function read_all_dir($dir){ $arr = array(); $hander = scandir($dir); //列出文件下的目录 foreach ($hander as $v) { //遍历文件夹下所有文文件 if (is_dir($dir . DS . $v) &原创 2021-04-01 14:29:29 · 190 阅读 · 0 评论 -
PHP对接腾讯地图 计算距离
腾讯地图function getCity($longitude, $latitude){ //调取腾讯接口,其中ak为key,注意location纬度在前,经度在后 $key = '*********'; $api = "https://apis.map.qq.com/ws/geocoder/v1/?location=" . $latitude . "," . $longitude . "&output=json&pois=1&key=" . $key;原创 2021-03-29 09:03:38 · 535 阅读 · 0 评论 -
生成小程序码
public function InserMiniAppQrCode($Goods_id, $UserId, $Path) { //小程序码 $options = [ 'app_id' => $this->AppId(), 'secret' => $this->Secret(), ]; $app = new Application($options);原创 2021-03-29 09:00:01 · 70 阅读 · 0 评论 -
指定时间起止时间戳
//日if ($param['status'] == 1) { $start_time = mktime(0, 0, 0, date('m'), date('d'), date('Y')); $end_time = mktime(0, 0, 0, date('m'), date('d') + 1, date('Y')) - 1;}//周if ($param['status'] == 2) { $start_time = mktime(0, 0, 0, date('m'),原创 2021-03-29 08:58:50 · 190 阅读 · 0 评论 -
按照指定字段排序
按照时间排序//降序public function test($person){newArr=array();foreach(newArr = array(); foreach (newArr=array();foreach(person as $key => $v) {newArr[newArr[newArr[key][‘createtime’] = KaTeX parse error: Expected 'EOF', got '}' at position 22: …atetim原创 2021-03-29 08:57:32 · 112 阅读 · 0 评论 -
判断当前时间是否是每月第一天
public function time(){$today = date("Y-m-d");$day = $this->getthemonth($today);if ($day[0] == $day[1]) { return True;} else { return False;}}function getthemonth($date){firstday=date(′Y−m−01′,strtotime(firstday = date('Y-m-01', strto原创 2021-03-29 08:56:46 · 2729 阅读 · 0 评论 -
RSA 加解密 非对称加密
RSA 加解密 非对称加密相关介绍RSA算法属于非对称加密算法,非对称加密算法需要两个秘钥:公开密钥(publickey)和私有秘钥(privatekey).公开密钥和私有秘钥是一对,如果公开密钥对数据进行加密,只有用对应的私有秘钥才能解密;如果私有秘钥对数据进行加密那么只有用对应的公开密钥才能解密.加密解密使用的是两个不同的秘钥,这种算法叫做非对称加密算法/公钥加密私钥解密,私钥加密公钥解密.需要注意的地方1.RSA 加密或签名后的结果是不可读的二进制,使用时经常会转为 BASE64 码再传原创 2021-03-26 11:50:26 · 334 阅读 · 0 评论 -
TP5 GD处理 头像处理圆形
function imagecircle($src, $dst){ //获取原图尺寸,并设置新图片的宽度和高度 //$src 原路径 $dst 保存路径 list($w, $h) = getimagesize($src); if ($w > $h) { $w = $h; } else { $h = $w; } $oimgSrc = imagecreatefromstring(file_get_contents(原创 2021-03-26 11:49:29 · 232 阅读 · 0 评论 -
PHP 时间戳转换成 刚刚 一小时前 等
public function tranTime($time) { $rtime = date("m-d H:i", $time); $htime = date("H:i", $time); $time = time() - $time; if ($time < 60) { $str = '刚刚'; } elseif ($time < 60 * 60) { ...原创 2021-03-26 11:33:24 · 346 阅读 · 0 评论 -
允许跨域请求
header("Access-Control-Allow-Origin: * ");header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE");if($_SERVER['REQUEST_METHOD'] == 'OPTIONS') { header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Auth原创 2021-03-26 11:32:10 · 161 阅读 · 0 评论