php
nextvary
这个作者很懒,什么都没留下…
展开
-
基于PHP、Python 开发Alfred workflow 工具
1、实现的功能快速生成 某文件中某接口的链路日志 查询语句效果 :2、原理根据输入的条件,生成符合条件的列表输出的格式:{ "items": [ { "title": "trace go_mutual_apply ", "subtitle": "grep `tail -1000 *go_mutual_apply*.log_json.20200512 |grep * | tail -1 |jq \".spanid\原创 2020-05-12 14:53:16 · 509 阅读 · 0 评论 -
gor 流量录制 && php 解析请求
1. 安装gorhttps://github.com/buger/goreplay下载后直接解压缩即可使用mac:下载地址linux:下载地址2, 使用gor 监听某接口,录制流量gor --input-raw :22771 --output-file origin_requests_%Y%m%d.log --output-file-append3,使...原创 2019-12-08 22:02:58 · 481 阅读 · 0 评论 -
php 数字转人民币大写金额(面试题)
思路:将数字分割成4个一组, 1111 //一千一百一是一<?php$int2=901010001;function transfer(string $int){ var_dump($int); $int=strrev($int); $flags=['4'=>'兆','3'=>'亿','2'=>'万','1'=>'']; $shu=['0'=>'',...原创 2018-04-26 13:36:12 · 343 阅读 · 0 评论 -
php 商品多规格的实现,sku实现
1,规格名称表CREATE TABLE `fa_item_attr_key` ( `attr_key_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `item_id` int(10) unsigned DEFAULT '0', `attr_name` varchar(50) NOT NULL, PRIMARY KEY (`att...原创 2018-08-20 13:55:37 · 18714 阅读 · 10 评论 -
Laravel 路由,只需定义一次以后模块化,无需每次写方法写控制器都要写一遍路由,RSTful API
Route::pattern('version_id', '[0-9]+');Route::group(['prefix'=>'v{version_id}'],function ($router){ $router->any('/{module}/{controller?}/{action?}/{id?}',function() use ($router){ ...原创 2018-09-03 12:16:44 · 2618 阅读 · 0 评论 -
爬虫:php实现 百度首页书签的获取,以及百度首页书签的迁移
1,获取旧账户的cookie,token等数据,从浏览器审查元素即可点击添加分类 即可获取到cookie token等数据 2,利用正则获取书签信息数据(获取旧账户的书签信息,并为新账户创建书签分类,并存储分类id,curl:为自己实现的类)public function actionCreatedir(){ $redis=Yii::$app->r...原创 2018-09-30 12:44:11 · 819 阅读 · 0 评论 -
PHP Composer 加载本地扩展包
目录结构: 项目下的 HttpServerFrame/composer.json{ "name": "xxx/http-server-demo", "authors": [ { "name": "xxx", "email": "xxx@xxx.com" } ], "autoload": { "psr-4": ...原创 2019-09-09 18:54:32 · 4416 阅读 · 0 评论 -
laravel model 类 数据库连接分析,如何建立数据库连接
第一步:实例化 Capsule ,这里的代码是框架自定义读取配置文件,进行orm的初始化第二步:这里将DatabaseManager 赋值给了 Model 类的$resolver 属性(下文还要用)第三步:进入正题了,调用model::where 方法,首先触发callStatic ,接着触发call 魔术方法第四步:newQuer...原创 2019-09-10 14:47:24 · 2222 阅读 · 0 评论 -
yii2 console 集成swoole 执行异步任务,例如注册邮件,发送短信
一,环境编译 参考地址: https://github.com/LinkedDestiny/swoole-doc/blob/master/01-%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA%E5%8F%8A%E6%89%A9%E5%B1%95%E5%AE%89%E8%A3%85.md二,项目部署 1,目录结构: ①,SwooleYiiApplicatio原创 2018-01-23 10:13:31 · 3620 阅读 · 0 评论 -
FirePHP 比var_dump 更好的调试方法
<?php require('./firephp.php');$fire=FirePHP::getInstance(true);$fire->info([123]);$fire->info('123');$fire->info(['a','b']);然后,安装chrome,firefox 插件chrome 效果:firefox效果: 下载地址: http://download.cs原创 2017-10-24 18:11:29 · 314 阅读 · 0 评论 -
php锁定记录,防止多人操作
<script type="text/javascript"> //编辑时锁定 function lock() { var controller = "<?= $this->context->id ?>"; var id = "<?= $id?>"; //发送锁定请求 $.getJSON('/admin.php?r=si原创 2017-04-13 11:04:33 · 1098 阅读 · 0 评论 -
yii2 xls自动上传,以及批量导入excel
先自动上传xls导入成功后,执行excel读取获取数据后,批量插入数据库 public function actionAddusers(){ $model=new OrgSearch(); if(!$org=$model->getOrg()){ exit('机构不存在'); } if (Yii::$a原创 2017-04-13 15:23:41 · 2386 阅读 · 0 评论 -
文件下载
public function actionDownloadxls(){ $file_path=dirname(__FILE__).'/'.iconv("utf-8","gb2312",'模板.xls'); // 输入文件标签 Header("Content-type: application/octet-stream"); Header("Accept-Range原创 2017-04-13 16:14:39 · 446 阅读 · 0 评论 -
PHPstorm Xdebug 调试(三张图就可以解决)
php.ini 设置[xdebug]zend_extension="F:\xampp\php\ext\php_xdebug.dll"xdebug.remote_enable = Onxdebug.remote_handler = dbgpxdebug.remote_host= localhostxdebug.remote_port = 9000xdebug.idekey = PHPST原创 2017-04-25 18:00:57 · 448 阅读 · 0 评论 -
获取指定时间戳的 周一 与 周日
function getWeekday($time){ $time=empty($time)?time():$time; $benzhou=date('w',$time);//1 $month=date('m',$time); $day=date('d',$time); $year=date('Y',$time); $data['first']=dat原创 2017-04-20 17:58:12 · 1801 阅读 · 0 评论 -
php后台管理,结合权限,动态生成栏目列表
思路:获取权限,生成父类栏目,在判断子栏目是不是在权限中,在的话,就拼接成html,返回,最后拼接父类栏目 返回/** * 返回org html * @return string */public static function getOrgMenu(){ $is_org_user=Yii::$app->session->get('org')->is_org_user;原创 2017-06-01 15:13:53 · 2049 阅读 · 0 评论 -
yii2 使用mysql ,实现点赞功能
/** *进行点赞 */ public function actionLike(){ Yii::$app->response->format=Response::FORMAT_JSON; $data = @json_decode(file_get_contents("php://input","r"),true); $top原创 2017-09-26 18:12:24 · 909 阅读 · 0 评论 -
yii2 redis队列,数据库表锁实现,点赞功能(10s内只可以点一次)
public function actionLike1(){ $data = @json_decode(file_get_contents("php://input","r"),true); $topic_id=$data['topic_id']; $redis = Yii::$app->redis; $ip=Yii::$app->requ原创 2017-09-26 18:09:05 · 2199 阅读 · 0 评论 -
yii2 文件上传
use yii\web\UploadedFile; //post过来的文件名,保存路径,保存文件名,允许的格式(数组形式)public function upload_file($file_name,$save_dir,$save_name,$file_type=['jpg','txt','xls','jpeg','png']){ if (!is_dir($dir=Yi原创 2017-04-13 11:00:52 · 504 阅读 · 0 评论