随笔分类 -  php小技巧

摘要:function sendPost($url, $path) { $curl = curl_init(); if (class_exists('\CURLFile')) { //PHP版本 >= 5.5 curl_setopt($curl, CURLOPT_SAFE_UPLOAD, true); $ 阅读全文
posted @ 2020-06-04 14:32 PHPer100 阅读(1286) 评论(0) 推荐(0)
摘要:/** * 父类P中 获取子类C的类名 */class P{ public static function getParent() { return self::class; } public static function getChild() { return static::class; } 阅读全文
posted @ 2020-03-12 10:30 PHPer100 阅读(900) 评论(0) 推荐(0)
摘要:/** * 删除缓存目录 * @param $dirname * @return bool */ function delCache($dirname) { $result = false; if (!is_dir($dirname)) { echo " $dirname is not... 阅读全文
posted @ 2019-07-20 20:25 PHPer100 阅读(2039) 评论(0) 推荐(0)
摘要:"; $data = ['a', 'b', 'c']; foreach($data as $key => $val){ $val = &$data[$key]; } echo "1."; var_dump($data); // 打印结果 // array(3) { [0]=> string(1) "b" [1]=> string(1) "c" [2]=> &string(1) "c" } /... 阅读全文
posted @ 2019-07-16 22:53 PHPer100 阅读(290) 评论(0) 推荐(0)
摘要:$v){ $preg = preg_match("/^($old_prefix{1})([a-zA-Z0-9_-]+)/i", $v[0], $v1); if($preg){ $tab_name[$k] = $v1[2]; } } if($preg){ foreach($tab_name as $k => $v)... 阅读全文
posted @ 2019-07-10 10:33 PHPer100 阅读(827) 评论(0) 推荐(0)
摘要:下载及安装redis 1.首先去github网站上下载https://github.com/dmajkic/redis/downloads; 2.根据实际情况,将64bit的内容cp到自定义盘符目录,如D:\Redis; 3.打开cmd,cd/d 切换到Redis-server.exe目录,运行re 阅读全文
posted @ 2019-07-06 02:51 PHPer100 阅读(6368) 评论(0) 推荐(0)
摘要:1、用round去小数点后两位时,有时候会出现很长的小数解决方法 使用sprintf再截取一遍。出现变态小数点不明原因。 2、小数点计算 bcadd — 将两个高精度数字相加 bccomp — 比较两个高精度数字,返回-1, 0, 1 bcdiv — 将两个高精度数字相除 bcmod — 求高精度数 阅读全文
posted @ 2019-07-06 02:40 PHPer100 阅读(2210) 评论(0) 推荐(0)
摘要:使用empty()函数判断,两者都是true 阅读全文
posted @ 2019-07-06 02:35 PHPer100 阅读(1386) 评论(0) 推荐(0)
摘要:function is_mobile_request(){ $_SERVER['ALL_HTTP'] = isset($_SERVER['ALL_HTTP']) ? $_SERVER['ALL_HTTP'] : ''; $mobile_browser = '0'; if(preg_match('/(up.browser|up.link|mmp|symbian|... 阅读全文
posted @ 2019-07-06 02:32 PHPer100 阅读(1632) 评论(0) 推荐(0)
摘要:1、获取ip 2、判断是否国内ip 3、怎么“越级”获取ip 当我们的服务器的接口需要获取终端ip,而对接我们的接口的是一个平台,我们采用方法1获取ip,只能获取到平台的ip。 解决方法: 方法1:接口是否form表单提交,这里我们采用方法1就能获取用户的ip (接口是真实处理的请求参数) 方法2: 阅读全文
posted @ 2019-07-06 02:30 PHPer100 阅读(523) 评论(0) 推荐(0)
摘要:1、下载sqlserver扩展 打开用phpinfo();查看php版本信息。如下 、 这里我使用的php7.2版本,sqlserver扩展的下载链接:https://github.com/Microsoft/msphpsql/releases 官方sqlserver扩展下载链接:https://w 阅读全文
posted @ 2019-05-13 09:54 PHPer100 阅读(28504) 评论(14) 推荐(1)
摘要:1 2 3 4 3 4 5'; $result = get_tag_data($temp,"div","class","num"); print_r($result); function get_tag_data($html,$tag,$class,$value){ //$value 为空,则获取class=$class的所有内容 $regex = $value ... 阅读全文
posted @ 2019-05-11 11:57 PHPer100 阅读(5311) 评论(1) 推荐(0)
摘要:#随机生成IP 中国区 function randip(){ $ip_1 = -1; $ip_2 = -1; $ip_3 = rand(0,255); $ip_4 = rand(0,255); $ipall = array( array(array(58,14),array(58,25)), array(array(58,30),arr... 阅读全文
posted @ 2019-04-27 16:09 PHPer100 阅读(1233) 评论(0) 推荐(0)
摘要:在有些支付文档或其他文档都会要求签名验证 上面的签名方法好像符合要求,结果调用报签名验证失败 后来在将 阅读全文
posted @ 2019-04-18 20:58 PHPer100 阅读(1056) 评论(0) 推荐(0)
摘要:[ 'student_id' => '学号', //key对应数据表wp_t_group_member的字段 'user_name' => '姓名', 'pinyin' => '拼音', 'user_email' => '邮箱', 'group_name' => '... 阅读全文
posted @ 2019-02-20 18:03 PHPer100 阅读(902) 评论(0) 推荐(0)
摘要:$logo = file_get_contents(IMG_URL.$logo); //根据头像的路径 $logo = yuanImg1($logo); //将头像改为圆形 $data = file_get_contents(IMG_URL.$img_url);//小程序的路径。如果没有保存,可以直接用微信小程序返回的资源 $data = qrcodeWithLogo(... 阅读全文
posted @ 2018-11-30 16:31 PHPer100 阅读(1373) 评论(0) 推荐(0)
摘要:function lock_url($txt,$key='www'){ $txt = $txt.$key; $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-=+"; $nh = rand(0,64); 阅读全文
posted @ 2018-11-14 13:41 PHPer100 阅读(187) 评论(0) 推荐(0)
摘要:第一种:加后缀 代码实现(就是普通的上传图片,只是在外面加个foreach循环) 代码实现 阅读全文
posted @ 2018-11-13 09:41 PHPer100 阅读(1059) 评论(0) 推荐(0)
摘要:<?php /*PHP正则提取图片img标记中的任意属性*/ $str = '<center><img src="/uploads/images/2017020716154162.jpg" height="120" width="120"><br />PHP正则提取或更改图片img标记中的任意属性< 阅读全文
posted @ 2018-11-08 10:30 PHPer100 阅读(1627) 评论(0) 推荐(0)