TypechoJoeTheme

至尊技术网

统计
登录
用户名
密码
/
注册
用户名
邮箱

悠悠楠杉

网站页面
搜索到 591 篇与 的结果
2022-09-03

原生js封装ajax

原生js封装ajax
function ajax(options) { var xhr = null; var type = 'GET'; var params = formsParams(options.data); if(typeof options.type != 'undefined'){ type = options.type.toUpperCase(); } //创建对象 if (window.XMLHttpRequest) { xhr = new XMLHttpRequest(); } else { xhr = new ActiveXObject("Microsoft.XMLHTTP"); } if (typeof options.async == "undefined") { options.async = true; } // 处理请求成功的回调函数 xhr.onload = function(){ if (xhr.status >= 200...
2022年09月03日
607 阅读
0 评论
2022-07-21

PHP面向对象的链式调用方式

PHP面向对象的链式调用方式
实现起来也还蛮简单的,只需要在每个方法最后返回$this就可以了<?php class wc { public function __construct($who) { echo "{$who}准备去上厕所了"; } public function go() { echo "1.跑出了教室"; return $this; } public function action($ss) { echo $ss . "2.到了厕所,开始尿尿"; return $this; } public function back() { echo "3.尿尿结束,回到教室"; return $this; } } $xm = new wc("小明"); $xm->go()->...
2022年07月21日
562 阅读
0 评论
2022-07-15

微信小程序长按事件

微信小程序长按事件
<view bindtouchstart="touchstart" bindtouchend="touchend">123456</view> //touch start touchstart: function(e) { this.startTime = e.timeStamp; console.log(this.startTime) }, //touch end touchend: function(e) { this.endTime = e.timeStamp; console.log(this.endTime) console.log("endTime - startTime = " + (this.endTime-this.startTime)); if (this.endTime - this.startTime>600){ console.log('长按') ...
2022年07月15日
607 阅读
0 评论
2022-06-16

ThinkPHP 过滤重复数据distinct和group

ThinkPHP 过滤重复数据distinct和group
//distinct方法去重 $data = (new classifyModel())->distinct(true)->field('name')->select()->toArray(); //group方法去重 $data = (new classifyModel())->group('name')->select()->toArray(); 对于两种去重方式: distinct去重、简单易用,但只能对于单一字段去重,并且最终的结果也仅为去重的字段,实际应用价值不是特别大。 group去重,最终的显示结果为所有字段,且对单一字段进行了去重操作,效果不错。
2022年06月16日
721 阅读
0 评论
2022-06-10

PHP面向对象封装MySQL PDO(已使用预处理)

PHP面向对象封装MySQL PDO(已使用预处理)
Mysql.class.php<?php class Mysql { public $link; public function __construct() { $this->conn(); } /** * 连接数据库,从配置文件读取配置信息 */ public function conn() { $cfg = require 'config.php'; try { $this->link = new PDO("mysql:dbname={$cfg['databaseName']};host={$cfg['host']};charset={$cfg['charset']};port={$cfg['port']}", $cfg['name'], $cfg['password']); $this->link->setAttribute(PDO::ATTR_EMU...
2022年06月10日
622 阅读
0 评论
2022-05-13

Linux find|grep|sed命令基本语法

Linux find|grep|sed命令基本语法
find命令语法:find [-H] [-L] [-P] [-D debugopts] [-Olevel] [path...] [expression] [action] 说明:path... 查找路径,可以指定多个,默认为当前路径expression 查找的条件,包括根据文件名、类型、大小、修改时间等进行查找,默认查找当前路径所有文件action: 处理动作,对符合条件的文件所做的操作,默认为显示到标准输出查找条件:-name 根据文件名查找, 支持glob,即包括: *,?,[],[^],来匹配文件名例如:find /etc/ -name passwd 精确查找 find /etc/ -name '*passwd*' 匹配查找 -iname 根据文件名查找,不区分大小写 -regex pattern 使用正则表达式来匹配文件(路径) grep命令1、在当前目录中,查找后缀有 file 字样的文件中包含 test 字符串的文件,并打印出该字符串的行:grep test *file2、以递归的方式查找符合条件的文件:grep -r test *3、反向查找:grep -v tes...
2022年05月13日
748 阅读
0 评论
2022-04-04

js实现html导出为PDF文件

js实现html导出为PDF文件
html2canvas官网:http://html2canvas.hertzen.com/<?php if(!empty($_POST['datauri'])){ if(preg_match('/data:.*?;base64,/i',$_POST['datauri'])){ $datauri = base64_decode(preg_replace('/data:.*?;base64,/i','',$_POST['datauri'])); $dir = 'upload/'; if(!is_dir($dir)){ mkdir($dir); } $file = md5($_SERVER['HTTP_USER_AGENT'] . $_SERVER['REMOTE_ADDR']).'.pdf'; try { file_put_contents($dir.$file,$datauri); $data = ['...
2022年04月04日
1,107 阅读
0 评论
2022-03-26

PHP将文件打包成zip

PHP将文件打包成zip
单文件压缩<?php $zip = new ZipArchive(); $zip_filename = "img/".time().".zip"; // 指定一个压缩包地址 $zip->open($zip_filename, ZIPARCHIVE::CREATE); // 打开压缩包,没有则创建 /* 第一个参数:要打开的压缩包文件 第二个参数: ZIPARCHIVE::OVERWRITE 总是创建一个新的文件,如果指定的zip文件存在,则会覆盖掉 ZIPARCHIVE::CREATE 如果指定的zip文件不存在,则新建一个 ZIPARCHIVE::EXCL 如果指定的zip文件存在,则会报错 ZIPARCHIVE::CHECKCONS 对指定的zip执行其他一致性测试 */ $zip->addFile("img/1.jpg",basename("2.jpg")); $res = $zip->close() 多文件压缩<?php $fileLis...
2022年03月26日
1,083 阅读
0 评论