php
liuxin_0725
这个作者很懒,什么都没留下…
展开
-
PHP 代码页面操作
是原创 2022-12-14 10:04:03 · 547 阅读 · 1 评论 -
php html页面 js一些操作
【代码】php html页面 js一些操作。原创 2022-12-14 09:41:05 · 169 阅读 · 0 评论 -
thinkphp5 命令行crontab定时执行访问控制器
进入到项目路径public下 再执行 php 框架index.php 入口文件 然后控制器。原创 2022-11-22 10:13:56 · 398 阅读 · 0 评论 -
php的错误输出到nginx的error_log中
通过FastCGI运行的PHP,在用户访问时出现错误,会首先写入到PHP的errorlog中如果PHP的errorlog无法写入,则会将错误内容返回给FastCGI接口,然后nginx在收到FastCGI的错误返回后记录到了nginx的errorlog中所以将php的错误输出到nginx的error_log中的办法:1.修改php-fpm.conf中配置,没有则增加catch_workers_output = yes;error_log = log/error_log2.修改php.ini中配置,没有则原创 2022-06-10 16:44:40 · 297 阅读 · 0 评论 -
php 计算两个日期 时间差 展示天时分秒
$begin_time 时间戳$$end_time 时间戳public function timediff($begin_time,$end_time) { if($begin_time < $end_time){ $starttime = $begin_time; $endtime = $end_time; }else{ $starttime = $end_time; $endtime = $beg.原创 2022-05-13 17:17:24 · 343 阅读 · 0 评论 -
PHP中关于时间(戳)、时区、本地时间、UTC时间等梳理
在PHP开发中,我们经常会在时间问题上被搞糊涂,比如我们希望显示一个北京时间,但是当我们使用date函数进行输出时,却发现少了8个小时。几乎所有的php猿类都必须对php中几个重要的时间转换等方法进行研究。本文就来梳理这些问题。时间戳(timestamp)GMT在时间戳这个点上,它是一个概念,而不是具体的编程问题,是计算机世界通用的一种约定。时间戳是指格林尼治时间(GMT)1970年01月01日00时00分00秒到当前时间的总秒数。GMT(也被称为世界时)是固定为本初子午线经过地区的时间,因原创 2022-04-19 16:34:58 · 2739 阅读 · 0 评论 -
html嵌入php代码 简写
<td height="30" width="50" <?php if($select_appid == 11111): ?>onclick="layer_show('xxxx.php?id=<?=date("Ymd",strtotime($val['dd_ts']));?>','今天',60,90)"<?php endif; ?> ><?=$select_appid;?></td><?php if($val['wit.原创 2022-04-16 14:43:43 · 81 阅读 · 0 评论 -
php redis加锁
$lockKey='withdraw_lock_'.$this->uid;$getLock = $this->cache_redis->set($lockKey, $this->uid, ['NX', 'EX'=>3]);if(!$getLock){ return;}原创 2022-03-10 21:39:40 · 1180 阅读 · 0 评论 -
php 生成日期代码
//当天开始 生成之后一周数据for ($i = 1; $i <= 7; $i++) { $ts = time(); $date = date("Ymd",$ts + (86400*($i-1)));}//当天开始 生成前一周数据for ($i = 1; $i <= 7; $i++) { $ts = time(); $date = date("Ymd",$ts - (86400*($i-1)));}$statime =164675520...原创 2022-03-08 10:50:47 · 338 阅读 · 0 评论 -
mysql 实现无则插入有则更新的
只要一个条件控制更新 可以直接使用id即可insert into newbie_stats_copy(id,reg) values(8888,4) ON DUPLICATE KEY update id=8888,reg=reg+3如果存在id 8888 就更新数据 reg+3,如果不存在则插入8888 reg=4如果两个条件控制更新 使用联合唯一索引ALTER TABLE `newbie_stats_copy`ADD UNIQUE INDEX `app_id` (`app_id`, `原创 2022-02-11 16:54:20 · 679 阅读 · 0 评论 -
php 操作mysql类
<?phpinclude_once(path_format('config/config.php'));class Mysql { private $conn = null; private $tag = "Mysql"; public function __construct() { } public function connect($c) { if(!isset($c['port'])){ $c['po.原创 2022-01-14 16:04:51 · 464 阅读 · 0 评论 -
php7 操作mongodb类
<?phpinclude_once(path_format('config/config.php'));class Mongo { private $tag = "Mongodb"; private $mongodb=''; private $db=''; private $table=''; private $filter=[]; private $option=[]; public function connect($c.原创 2022-01-14 16:03:42 · 593 阅读 · 1 评论 -
php 大转盘 抽奖概率算法
随机输出“苹果”,“橘子”,“香蕉”要求输出“苹果”的概率为50%,“橘子”的概率为30%,“香蕉”的概率为20%1.第一种算法function getRandom($pr){ $temp = rand(0,array_sum($pr)); $left = 0; $right = 0; foreach ($pr as $k=>$v){ $right+=$v; if($left<=$temp && $tem.原创 2020-08-10 11:13:50 · 1087 阅读 · 0 评论 -
php 保留两位小数 不四舍五入
substr(sprintf("%.3f",$value),0,-1); //保留两位小数 不四舍五入原创 2020-08-07 11:35:19 · 575 阅读 · 0 评论 -
PHP按字符串长度分割成数组代码(中英文混杂字符进行分割)
print_r($this->ch2arr('123肉rbv地 方'));Array( [0] => 1 [1] => 2 [2] => 3 [3] => 肉 [4] => r [5] => b [6] => v [7] => 地 [8] => [9] => 方)//空格也算一个字符 function ch2arr($str) ...原创 2020-07-20 17:43:14 · 619 阅读 · 0 评论 -
PHP redis SCAN、SSCAN、ZSCAN、HSCAN 的使用, pipe 快速redis插入数据
SCANSCAN cursor [MATCH pattern] [COUNT count] 作用:迭代当前数据库中的数据库键 SCAN 使用 demo <?php$redis = new Redis();$redis->connect('127.0.0.1', 6379);/* Options for the SCAN family of commands, indicating whether to abstract empty results from the use原创 2020-05-15 11:42:33 · 1157 阅读 · 0 评论 -
PHP7 mongoDB操作
查询 区分变量类型 需注意 $where=[ 'league_id'=>$club_id, 'uid'=>(int)$this->uid, //位数过长的 必须转类型 'ts'=>['$gte' => 1585670400,'$lt' => 1585756800], //ts是4月1日至4月2日零点前 'vid'=...原创 2020-04-01 16:19:22 · 267 阅读 · 0 评论 -
php 导出Csv文件
public function exportCsv($heade=[],$data=[],$fileName='导出'){ set_time_limit(0); ini_set('memory_limit', '256M'); $fileName = $fileName.'.csv'; header('Content-Description: File Tra...原创 2020-01-15 17:15:31 · 156 阅读 · 0 评论 -
记录PHP错误日志,php-fpm中启用慢日志配置(用于检测执行较慢的PHP脚本)
1、记录PHP错误日志display_errors与log_errors的区别display_errors错误回显,一般常用于开发模式,但是很多应用在正式环境中也忘记了关闭此选项。错误回显可以暴露出非常多的敏感信息,为攻击者下一步攻击提供便利。推荐关闭此选项。display_errors = On开启状态下,若出现错误,则报错,出现错误提示dispaly_errors = Of...原创 2020-01-08 22:21:27 · 531 阅读 · 0 评论 -
centos 多版本php运用
1、用户组需要将两个版本的用户组区分开方便管理,也可以使用同用户组#用来管理PHP5.6的groupadd php56useradd -g php5.6 php56#用来管理PHP7.2的groupadd php72useradd -g php72 php722、安装./configure时都指定安装位置#php5.6的--prefix='/usr/local/p...原创 2019-12-12 20:00:42 · 135 阅读 · 0 评论 -
php 根据两点间的经纬度计算距离
/** * @desc 根据两点间的经纬度计算距离 * @param float $lat 纬度值 * @param float $lng 经度值 */public function getDistance($lat1, $lng1, $lat2, $lng2) { $earthRadius = 6367000; $lat1 = ($lat1 * pi() )...原创 2019-11-27 19:22:36 · 139 阅读 · 0 评论 -
php execl 通过echo简单导出
//获取数据 $list=Ativity::getTw_statisticExecl($activity_id,$status); // execl导出 header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachme原创 2016-07-31 20:15:31 · 370 阅读 · 0 评论 -
php 生成二维码
下载phpqrcode.php 引入文件使用 参数 地址 路径 图片名称更多方法参数 自行百度$png = QRcode::png('www.baidu.com','uploads/'.$activity_id.'.png');原创 2016-07-31 22:18:22 · 162 阅读 · 0 评论 -
php上传
//判断是否post提交 if ($_SERVER['REQUEST_METHOD'] == 'POST') { //ajax返回 $ret=array('strings'=>$_POST,'error'=>'0'); $fs=array(); //循环传过来的图片对象 foreach ( $_FILES as $name=>$f原创 2017-01-04 10:03:48 · 275 阅读 · 0 评论 -
php 两种方法获取url内容 file_get_contents和curl
public function getLotteryNum() { //获取url内容 $retData = @file_get_contents('url'); //判断是否存在rul返回的信息 if(isset($http_response_header)){ $data = json_decode($retDa原创 2016-12-28 11:56:19 · 11071 阅读 · 1 评论 -
php 生成百万数,不重复,并且打乱数字顺序,插入数据库
按生成100000个幸运数字,从1开始生成有序的数组元素 $num_info = range (1,100000); 打乱数组下标 shuffle($num_info); 按10000再将num_info拆成二维数组 $num_info_sum = array_chunk($num_info,10000); .循环拆分的原创 2016-12-28 17:31:45 · 2419 阅读 · 0 评论 -
正则验证函数 前后台 php验证,jquery前台验证
php后台 if(!preg_match("/^[1-9][0-9]*$/",$value))//当不为整数时 { $this->jsAlert('请输入整数,不能带小数点','/index.php/manager/Managerset/distributionset'); }前台jquery if(原创 2016-12-20 14:55:38 · 757 阅读 · 0 评论 -
thinkphp5 sql函数
count用法 字段写在count里面Db::table('ys_users_parent')->count('distinct parent');条件搜索加where Db::table('pay_order')->where('pay_time>0')->count();$kaishi = strtotime('1 minute',strtotime($input_d原创 2016-12-13 19:29:05 · 2111 阅读 · 0 评论 -
jq获取后台传过来的json格式数据
前台var payurl = "/index.php/wap/user/ajaxrecharge";$.post(payurl,{money:account},function(data){ var josnobj = eval("("+data+")"); $.each(josnobj,function(name,value) { alert(val原创 2016-12-13 16:57:23 · 3263 阅读 · 0 评论 -
微信禁止下拉代码
var touchPageYStart=0;try{if($.isFunction(eval(etouch))){var touch=etouch}}catch(e){var touch=function(event){var event=event||window.event;var eot=event.touches[0];switch(event.type){case"touchstart"原创 2016-11-15 15:58:43 · 2998 阅读 · 1 评论 -
php 日期获取代码 生成一周日期代码
时间戳转换比如,今天是2102年11月2号,那么php要获取2102年11月2号的时间戳是怎么办的呢?代码:echo strtotime(date('Y-m-d')),'获取明天凌晨的时间戳代码:echo strtotime(date('Y-m-d',strtotime('+1 day'))),'最后再附一串代码echo "今天:".date("Y-m-d"原创 2016-09-05 11:53:50 · 642 阅读 · 0 评论 -
jquery ajax 地级三级菜单
前端 公司区域: 请选择 {volist name="area_list" id="i"} {$i.name} {/volist} $("#shengji").change(function(){ var val原创 2016-08-20 16:12:35 · 244 阅读 · 0 评论 -
php 三表查询集合分组,排序,别名,集合函数
/** * getAgentByIncome 通过用户购买查询用户列表(包括累积购买和红包) * @karl * @DateTime 2016-08-01T13:23:44+0800 * @param array $where 查询条件 * @param integer原创 2016-08-03 16:56:42 · 671 阅读 · 0 评论 -
bootstrap-datetimepicker日历控件
引入文件 html代码 起 <input type="text" class="form-control" id="end_time" name="end_time" maxlength="20" placeholder="2016-2-2 02:00" style="width: 160px;display:inline-block;" > 止jq原创 2016-07-31 22:05:07 · 429 阅读 · 0 评论 -
两个时间数据求它的相差小时,分钟等等
System.TimeSpan tsDiff = Convert.ToDateTime(BeginTime) - Convert.ToDateTime(OverTime); int d = System.Math.Abs(tsDiff.Days);//两时间相差天数 int h = System.Math.Abs(tsDiff.Hours);原创 2011-06-22 14:56:00 · 492 阅读 · 0 评论 -
mysql 经纬度坐标算距离
$lng是你的经度,$lat是你的纬度 SELECT lng,lat, (POWER(MOD(ABS(lng - $lng),360),2) + POWER(ABS(lat - $lat),2)) AS distance FROM `user_location` ORDER BY distance LIMIT 100转载 2017-03-31 11:01:35 · 745 阅读 · 0 评论 -
php面试题目
0.简单做一下自我介绍,? 然后谈一下近三年来你的得意之作?1.面试官看过你的简历,会问一些你做的项目的用户量、pv、吞吐量、相关难点和解决方法等2.数据库设计经验,为什么进行分表? 分库?一般多少数据量开始分表? 分库? 分库分表的目的? 什么是数据库垂直拆分? 水平拆分? 分区等等?可以举例说明3.数据库优化有哪些? 分别需要注意什么?4.web开发方面会遇到哪些缓转载 2017-07-11 17:55:44 · 343 阅读 · 0 评论 -
php post get提交
//只支持http提交 public function send($url=false,$data=false){if(!$url || !$data) return false;$ch = curl_init();// 创建连接对象curl_setopt($ch, CURLOPT_URL, $url);// 指定请求的URLcurl_setopt($ch, CURLO原创 2017-07-03 17:45:46 · 494 阅读 · 0 评论 -
php 设置临时内存和超时设置脚本最大执行时间
ini_set('memory_limit','3072M'); // 临时设置最大内存占用为3G set_time_limit(0); // 设置脚本最大执行时间 为0 永不过期原创 2017-07-05 14:10:20 · 41867 阅读 · 1 评论 -
接受图片流并且生成图片
第一种 $res= file_put_contents(‘路径加图片名称’, base64_decode(‘图片流数据’)); if($res===false) throw new \Exception('生成图片失败');生成成功会返回数字,失败为空第二种原创 2017-07-25 09:49:54 · 2623 阅读 · 0 评论