tp5 验证器 分类验证
TP / 2019-07-10

验证类代码: protected $rule = [ ‘company|公司名称’ => ‘require’, ‘name|联系人’ => ‘require’, ‘tel|联系方式’ => ‘require|number’, ‘describe|描述’ => ‘require’, ]; protected $scene = [ //商业合作 ‘commerce’ =>…

地图收索最近的店铺–代码记录
TP / 2019-07-09

代码 /* *参数说明: *$lng 经度 *$lat 纬度 *$distance 周边半径 默认是10公里(0.5Km) */ public function returnSquarePoint($lng, $lat, $distance = 10) { $dlng = 2 * asin(sin($distance / (2 * 6371)) / cos(deg2rad($lat))); $dl…

php redis并发处理
Redis , TP / 2019-06-13

//php秒杀 redis并发处理 public function miaoshao() { $redis = new Redis;//diy redis操作类 $kuchun = $redis -> get(‘kucun’); $total = 100; if ($kuchun <= $total){ //有库存 $redis -> watch(‘kucun’); //开启事务…

图片上传(单图/多图)
TP / 2019-06-13

// 应用公共文件 function fail($msg = ”, $data = []) { return empty($data) ? json_encode([‘statu’ => 0, ‘msg’ => empty($msg) ? ‘request fail.’ : $msg], JSON_UNESCAPED_UNICODE) : json_encode([‘statu’ =…

php 抓取网页内容
TP / 2019-05-21

$url = ‘https://h5.youzan.com/v2/showcase/goods?alias=2osqyf87mz1jb’; $str = file_get_contents($url);//抓取网页的源代码 $rule = ‘/<p><img src=(.*?)<\/p>/i’; preg_match_all($rule,$str,$py_data);…

微信表情存入数据库错,过滤方法
Mysql , TP / 2019-05-18

代码为: $string = preg_replace(‘/[\x{10000}-\x{10FFFF}]/u’, ”, $string); 如果还需要过滤其他的非法字符: $string = preg_replace(‘/[\x{1F600}-\x{1F64F}]/u’, ”, $string); $string = preg_replace(‘/[\x{1F300}-\x{1F5FF}]/u…

表格导出
TP / 2019-04-07

123456789101112131415161718192021222324252627282930//表格导出 public function sign_excel() { if($this-&gt;request-&gt;isPost()) { $ids = $this-&gt;request-&gt;param(‘ids/s’); $map = []; $m…

php excel操作
TP / 2019-04-07

PHPExcel文件:PHPExcel git下载地址:             https://github.com/PHPOffice/PHPExcel 123456789101112131415161718192021222324252627282930313233343536//导入 public function inserExcel() { if(request() -&gt;…

CURL
TP / 2019-04-03

public function curl_get($url) { //初始化 $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); // 执行后不直接打印出来 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, false); // …