首页
友链
壁纸
留言
今日热榜
更多
关于
时光
推荐
精品流量卡
Search
1
都二十多年了,你的梦为什么还没碎!
57,051 阅读
2
2022年5个好用的 BT/ 磁力链接下载工具推荐 |Windows 、安卓系统
37,158 阅读
3
nps内网穿透实现外网访问树莓派
32,370 阅读
4
实践利用宝塔建emlog个人博客-超详细【原创】
26,116 阅读
5
Typecho-Joe-Theme主题帮助文档
24,518 阅读
闲杂乱码
Python
网站源码
微信小程序
娱乐分享
Is相册
软件工具
登录
Search
标签搜索
PHP
HTML
API
Javascript
源码
JS
Vue
Github
CloudFlare
接口
函数
SQL
ASP.NET
MVC
EF
T4模板
后台管理
CDN
微信小程序
MAC
韩小韩
累计撰写
261
篇文章
累计收到
1,296
条评论
首页
栏目
闲杂乱码
Python
网站源码
微信小程序
娱乐分享
Is相册
软件工具
页面
友链
壁纸
留言
今日热榜
关于
时光
推荐
精品流量卡
搜索到
18
篇与
PHP
的结果
2021-02-26
MAC上PHP集成开发环境搭建
{message type="info" content="用惯了在Windows上配置php开发环境,要在MAC上捣腾一个PHP开发环境还不大习惯,那mac上php开发环境怎么搭建配置呢?有哪些集成软件呢?"/}{message type="success" content="本文为你推荐几款常用的mac php环境软件,并介绍这些软件的安装与配置教程,下面一起动手搭建一个macbook php开发环境吧!"/}mac php开发集成环境搭建软件推荐:{callout color="#f0ad4e"}MAMP(Macintosh+Apache+MySQL+PHP)MAMP Free版(免费版)即可,功能够用, Pro是收费版本免费版本学习足够了{/callout}{cloud title="MAMP & MAMP PRO for mac版下载地址" type="default" url="https://www.mamp.info/de/downloads/" password=""/}xampp for mac(Apache+MySQL+PHP+PERL){callout color="#f0ad4e"} 主要是免费 mac 可以安装xampp for mac {/callout}{cloud title="xampp for mac版下载地址" type="default" url="https://www.apachefriends.org/zh_cn/download.html" password=""/}phpstudy mac版本{callout color="#f0ad4e"} phpstudy mac版已经开发完成{/callout}{cloud title="phpstudy mac版下载地址" type="default" url="https://public.xp.cn/upgrades/phpstudy_install.dmg" password=""/}MAC自带PHP环境{callout color="orange"}使用Brew 命令, 通过终端安装PHP与MySQL等,mac自带的php版本太低{/callout}
2021年02月26日
2,662 阅读
10 评论
1 点赞
2021-01-20
PHP函数大全·持续更新
邮箱验证function is_valid_email($email) { if (preg_match('/^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/', $email)) { return true; } else { return false; } } OR function check_email($email) { $result = trim($email); if (filter_var($result, FILTER_VALIDATE_EMAIL)) { return true; } else { return false; } }301跳转function redirect($url) { header('location:'.$url, false, 301); exit; }获取客户端IPfunction real_ip($type = 0) { $ip = $_SERVER['REMOTE_ADDR']; if ($type <= 0 && isset($_SERVER['HTTP_X_FORWARDED_FOR']) && preg_match_all('#\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}#s', $_SERVER['HTTP_X_FORWARDED_FOR'], $matches)) { foreach ($matches[0] as $xip) { if (filter_var($xip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) { $ip = $xip; break; } } } elseif ($type <= 0 && isset($_SERVER['HTTP_CLIENT_IP']) && filter_var($_SERVER['HTTP_CLIENT_IP'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) { $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif ($type <= 1 && isset($_SERVER['HTTP_CF_CONNECTING_IP']) && filter_var($_SERVER['HTTP_CF_CONNECTING_IP'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) { $ip = $_SERVER['HTTP_CF_CONNECTING_IP']; } elseif ($type <= 1 && isset($_SERVER['HTTP_X_REAL_IP']) && filter_var($_SERVER['HTTP_X_REAL_IP'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) { $ip = $_SERVER['HTTP_X_REAL_IP']; } return $ip; }X_FORWARDED_FOR:之前的获取真实IP方式,极易被伪造IPX_REAL_IP:在网站使用CDN的情况下选择此项,在不使用CDN的情况下也会被伪造REMOTE_ADDR:直接获取真实请求IP,无法被伪造,但可能获取到的是CDN节点IP取中间文本function getSubstr($str, $leftStr, $rightStr) { $left = strpos($str, $leftStr); $right = strpos($str, $rightStr, $left); if ($left < 0) return ''; if ($right > 0) { return substr($str, $left + strlen($leftStr), $right - $left - strlen($leftStr)); } else { return substr($str, $left + strlen($leftStr)); } }是否HTTPS访问function is_https() { if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) { return true; } elseif (isset($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) == 'on' || $server['HTTPS'] == '1')) { return true; } elseif (isset($_SERVER['HTTP_X_CLIENT_SCHEME']) && $_SERVER['HTTP_X_CLIENT_SCHEME'] == 'https') { return true; } elseif (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') { return true; } elseif (isset($_SERVER['REQUEST_SCHEME']) && $_SERVER['REQUEST_SCHEME'] == 'https') { return true; } elseif (isset($_SERVER['HTTP_EWS_CUSTOME_SCHEME']) && $_SERVER['HTTP_EWS_CUSTOME_SCHEME'] == 'https') { return true; } return false; }随机IPfunction randIp() { return mt_rand(0, 255) . '.' . mt_rand(0, 255) . '.' . mt_rand(0, 255) . '.' . mt_rand(0, 255); }毫秒时间戳function msectime() { list($msec, $sec) = explode(' ', microtime()); return (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000); }获取重定向地址function getrealurl($url){ @$header = get_headers($url,1); if (strpos($header[0],'301') || strpos($header[0],'302')) { if(is_array($header['Location'])) { return $header['Location'][count($header['Location'])-1]; }else{ return $header['Location']; } }else { return $url; } }jsonp转数组function jsonp_decode($jsonp, $assoc = false) { $jsonp = trim($jsonp); if (isset($jsonp[0]) && $jsonp[0] !== '[' && $jsonp[0] !== '{') { $begin = strpos($jsonp, '('); if (false !== $begin) { $end = strrpos($jsonp, ')'); if (false !== $end) { $jsonp = substr($jsonp, $begin + 1, $end - $begin - 1); } } } return json_decode($jsonp, $assoc); }秒数转换详细时间/** * 将秒数转换为剩余详细时间! */ function Sec2Time($time) { if (is_numeric($time)) { $value = array( "years" => 0, "days" => 0, "hours" => 0, "minutes" => 0, "seconds" => 0, ); if ($time >= 31556926) { $value["years"] = floor($time / 31556926); $time = ($time % 31556926); } if ($time >= 86400) { $value["days"] = floor($time / 86400); $time = ($time % 86400); } if ($time >= 3600) { $value["hours"] = floor($time / 3600); $time = ($time % 3600); } if ($time >= 60) { $value["minutes"] = floor($time / 60); $time = ($time % 60); } $value["seconds"] = floor($time); $t = ($value["years"] >= 1 ? $value["years"] . "年" : '') . ($value["days"] >= 1 ? $value["days"] . "天" : '') . ($value["hours"] >= 1 ? $value["hours"] . "小时" : '') . ($value["minutes"] >= 1 ? $value["minutes"] . "分" : '') . ($value["seconds"] >= 1 ? $value["seconds"] . "秒" : ''); return (!empty($t) ? $t : '0秒'); } else { return (bool) FALSE; } }时间相差秒数/** * @param $startdate 开始时间 * @param int $enddate 结束时间 * 返回两者之间相差多少秒 */ function TimeLag($startdate, $enddate = -1) { global $date; $enddate = ($enddate == -1 ? $date : $enddate); $time = strtotime($enddate) - strtotime($startdate); //和结束时间的时间戳 $text = ''; $dater = floor(($time) / 86400); if ($dater > 0) { $time = $time - ($dater * 86400); $text .= $dater . '天'; } $hour = floor(($time) / 3600); if ($hour > 0) { $time = $time - ($hour * 3600); $text .= $hour . '小时'; } $minute = floor(($time) / 60); $time = $time - ($minute * 60); if ($minute > 0) { $text .= $minute . '分钟'; } $second = floor(($time) % 60); if ($second > 0) { $text .= $second . '秒'; } return $text; }生成唯一token参数/** * @param $vals 混淆函数 * 生成唯一token参数! */ function TokenCreate($vals = '1') { $key = mt_rand(); $hash = hash_hmac("sha1", $vals . mt_rand() . time(), $key, true); return str_replace(['=', '_', '-'], '', strtr(base64_encode($hash), '+/', '-_')); }
2021年01月20日
1,114 阅读
0 评论
0 点赞
2021-01-15
PHP上传URL地址网络文件到服务器
如何将一个URL地址的网络资源文件上传到服务器?首先考虑的方法是将文件下载到本地,然后进行上传操作,那有没有一个更方便的方法,将一个网络文件直接上传到服务器呢?是不是可以通过文件流的方式上传呢?我这里使用的是 Guzzle 三方库,将一张百度上的图片上传到其他服务器。use GuzzleHttp\Client; try { $file = fopen('https://t8.baidu.com/it/u=1484500186,1503043093&fm=79&app=86&size=h300&n=0&g=4n&f=jpeg', 'r'); $multipart = [ [ 'name' => 'file', 'contents' => $file ] ]; $client = new Client(['verify' => false]); $response = $client->request('POST', 'https://xx.com/upload', [ 'multipart' => $multipart ]); if ($response->getStatusCode() === 200) { $content = $response->getBody()->getContents(); $result = json_decode($content, true); } } catch (\Exception $exception) { echo $exception->getMessage(); } return $result;
2021年01月15日
1,607 阅读
2 评论
2 点赞
2020-08-26
比较上档次的代码注释
好多同学都喜欢在代码的行行间间留下一些自己喜欢的东西,博主给大家分享一些比较🐮X的注释。直接上代码/*** * 瓦瓦 十 * 十齱龠己 亅瓦車己 * 乙龍龠毋日丶 丶乙己毋毋丶 * 十龠馬鬼車瓦 己十瓦毋毋 * 鬼馬龠馬龠十 己己毋車毋瓦 * 毋龠龠龍龠鬼乙丶丶乙車乙毋鬼車己 * 乙龠龍龍鬼龍瓦 十瓦毋乙瓦龠瓦亅 * 馬齱龍馬鬼十丶日己己己毋車乙丶 * 己齱馬鬼車十十毋日乙己己乙乙 * 車馬齱齱日乙毋瓦己乙瓦日亅 * 亅車齺龖瓦乙車龖龍乙乙十 * 日龠龠十亅車龍毋十十 * 日毋己亅 己己十亅亅 * 丶己十十乙 丶丶丶丶丶 * 亅己十龍龖瓦 丶 丶 乙十 * 亅己十龠龖毋 丶丶 丶己鬼鬼瓦亅 * 十日十十日亅丶亅丶 丶十日毋鬼馬馬車乙 * 十日乙十亅亅亅丶 十乙己毋鬼鬼鬼龍齺馬乙 * 丶瓦己乙十十亅丶亅乙乙乙己毋鬼鬼鬼龍齱齺齺鬼十 * 乙乙十十十亅乙瓦瓦己日瓦毋鬼鬼龠齱齱龍龍齱齱毋丶 * 亅十十十十乙瓦車毋瓦瓦日車馬龠龍龍龍龍龍龠龠龠馬亅 * 十十十十己毋車瓦瓦瓦瓦鬼馬龠龍龠龠龍龠龠龠馬龠車 * 亅十十日毋瓦日日瓦鬼鬼鬼龠龠馬馬龠龍龍龠馬馬車 * 亅亅亅乙瓦瓦毋車車車馬龍龠鬼鬼馬龠龍龍龠馬馬鬼 * 丶丶乙亅亅乙車鬼鬼鬼毋車龍龍龠鬼馬馬龠龍齱齱龍馬鬼 * 亅己十十己十日鬼鬼車瓦毋龠龍龠馬馬龠龠龠齱齺齺齱龠鬼 * 亅乙乙乙十車馬車毋馬齱齱龍龠龠龠馬龠龍齱龍龠龠鬼瓦 * 丶毋龠鬼車瓦車馬龠龍龠龠龍齱齱龠馬馬鬼毋日 * 十乙己日十 丶己鬼龍齱齺齱龍馬馬馬車毋己 * 丶十己乙亅丶 亅瓦馬龠龍龠龠馬毋瓦乙 * 丶十十乙亅十 亅己瓦車馬龠鬼車瓦乙 * 丶十乙十十丶 丶丶亅十瓦鬼車瓦己 * 丶亅亅丶 亅日瓦日 * 丶 *//*** * ┌───┐ ┌───┬───┬───┬───┐ ┌───┬───┬───┬───┐ ┌───┬───┬───┬───┐ ┌───┬───┬───┐ * │Esc│ │ F1│ F2│ F3│ F4│ │ F5│ F6│ F7│ F8│ │ F9│F10│F11│F12│ │P/S│S L│P/B│ ┌┐ ┌┐ ┌┐ * └───┘ └───┴───┴───┴───┘ └───┴───┴───┴───┘ └───┴───┴───┴───┘ └───┴───┴───┘ └┘ └┘ └┘ * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ ┌───┬───┬───┐ ┌───┬───┬───┬───┐ * │~ `│! 1│@ 2│# 3│$ 4│% 5│^ 6│& 7│* 8│( 9│) 0│_ -│+ =│ BacSp │ │Ins│Hom│PUp│ │N L│ / │ * │ - │ * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ ├───┼───┼───┤ ├───┼───┼───┼───┤ * │ Tab │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │{ [│} ]│ | \ │ │Del│End│PDn│ │ 7 │ 8 │ 9 │ │ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤ └───┴───┴───┘ ├───┼───┼───┤ + │ * │ Caps │ A │ S │ D │ F │ G │ H │ J │ K │ L │: ;│" '│ Enter │ │ 4 │ 5 │ 6 │ │ * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────────┤ ┌───┐ ├───┼───┼───┼───┤ * │ Shift │ Z │ X │ C │ V │ B │ N │ M │< ,│> .│? /│ Shift │ │ ↑ │ │ 1 │ 2 │ 3 │ │ * ├─────┬──┴─┬─┴──┬┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬────┬────┤ ┌───┼───┼───┐ ├───┴───┼───┤ E││ * │ Ctrl│ │Alt │ Space │ Alt│ │ │Ctrl│ │ ← │ ↓ │ → │ │ 0 │ . │←─┘│ * └─────┴────┴────┴───────────────────────┴────┴────┴────┴────┘ └───┴───┴───┘ └───────┴───┴───┘ *//*** * _ooOoo_ * o8888888o * 88" . "88 * (| -_- |) * O\ = /O * ____/`---'\____ * . ' \\| |// `. * / \\||| : |||// \ * / _||||| -:- |||||- \ * | | \\\ - /// | | * | \_| ''\---/'' | | * \ .-\__ `-` ___/-. / * ___`. .' /--.--\ `. . __ * ."" '< `.___\_<|>_/___.' >'"". * | | : `- \`.;`\ _ /`;.`/ - ` : | | * \ \ `-. \_ __\ /__ _/ .-` / / * ======`-.____`-.___\_____/___.-`____.-'====== * `=---=' * * ............................................. * 佛祖保佑 永无BUG *//*** * 佛曰: * 写字楼里写字间,写字间里程序员; * 程序人员写程序,又拿程序换酒钱。 * 酒醒只在网上坐,酒醉还来网下眠; * 酒醉酒醒日复日,网上网下年复年。 * 但愿老死电脑间,不愿鞠躬老板前; * 奔驰宝马贵者趣,公交自行程序员。 * 别人笑我忒疯癫,我笑自己命太贱; * 不见满街漂亮妹,哪个归得程序员? *//*** * _ooOoo_ * o8888888o * 88" . "88 * (| -_- |) * O\ = /O * ___/`---'\____ * . ' \\| |// `. * / \\||| : |||// \ * / _||||| -:- |||||- \ * | | \\\ - /// | | * | \_| ''\---/'' | | * \ .-\__ `-` ___/-. / * ___`. .' /--.--\ `. . __ * ."" '< `.___\_<|>_/___.' >'"". * | | : `- \`.;`\ _ /`;.`/ - ` : | | * \ \ `-. \_ __\ /__ _/ .-` / / * ======`-.____`-.___\_____/___.-`____.-'====== * `=---=' * ............................................. * 佛曰:bug泛滥,我已瘫痪! *//*** * ┌─┐ ┌─┐ * ┌──┘ ┴───────┘ ┴──┐ * │ │ * │ ─── │ * │ ─┬┘ └┬─ │ * │ │ * │ ─┴─ │ * │ │ * └───┐ ┌───┘ * │ │ * │ │ * │ │ * │ └──────────────┐ * │ │ * │ ├─┐ * │ ┌─┘ * │ │ * └─┐ ┐ ┌───────┬──┐ ┌──┘ * │ ─┤ ─┤ │ ─┤ ─┤ * └──┴──┘ └──┴──┘ * 神兽保佑 * 代码无BUG! *//*** * ___====-_ _-====___ * _--^^^#####// \\#####^^^--_ * _-^##########// ( ) \\##########^-_ * -############// |\^^/| \\############- * _/############// (@::@) \\############\_ * /#############(( \\// ))#############\ * -###############\\ (oo) //###############- * -#################\\ / VV \ //#################- * -###################\\/ \//###################- * _#/|##########/\######( /\ )######/\##########|\#_ * |/ |#/\#/\#/\/ \#/\##\ | | /##/\#/ \/\#/\#/\#| \| * ` |/ V V ` V \#\| | | |/#/ V ' V V \| ' * ` ` ` ` / | | | | \ ' ' ' ' * ( | | | | ) * __\ | | | | /__ * (vvv(VVV)(VVV)vvv) * 神兽保佑 * 代码无BUG! *//*** * * * __----~~~~~~~~~~~------___ * . . ~~//====...... __--~ ~~ * -. \_|// |||\\ ~~~~~~::::... /~ * ___-==_ _-~o~ \/ ||| \\ _/~~- * __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ * _-~~ .=~ | \\-_ '-~7 /- / || \ / * .~ .~ | \\ -_ / /- / || \ / * / ____ / | \\ ~-_/ /|- _/ .|| \ / * |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ * ' ~-| /| |-~\~~ __--~~ * |-~~-_/ | | ~\_ _-~ /\ * / \ \__ \/~ \__ * _--~ _/ | .-~~____--~-/ ~~==. * ((->/~ '.|||' -_| ~~-/ , . _|| * -_ ~\ ~~---l__i__i__i--~~_/ * _-~-__ ~) \--______________--~~ * //.-~~~-~_--~- |-------~~~~~~~~ * //.-~~~--\ * 神兽保佑 * 代码无BUG! *//*** ************************************************************** * * * .=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-. * * | ______ | * * | .-" "-. | * * | / \ | * * | _ | | _ | * * | ( \ |, .-. .-. ,| / ) | * * | > "=._ | )(__/ \__)( | _.=" < | * * | (_/"=._"=._ |/ /\ \| _.="_.="\_) | * * | "=._"(_ ^^ _)"_.=" | * * | "=\__|IIIIII|__/=" | * * | _.="| \IIIIII/ |"=._ | * * | _ _.="_.="\ /"=._"=._ _ | * * | ( \_.="_.=" `--------` "=._"=._/ ) | * * | > _.=" "=._ < | * * | (_/ \_) | * * | | * * '-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=' * * * * LASCIATE OGNI SPERANZA, VOI CH'ENTRATE * ************************************************************** *//*** * ,s555SB@@& * :9H####@@@@@Xi * 1@@@@@@@@@@@@@@8 * ,8@@@@@@@@@B@@@@@@8 * :B@@@@X3hi8Bs;B@@@@@Ah, * ,8i r@@@B: 1S ,M@@@@@@#8; * 1AB35.i: X@@8 . SGhr ,A@@@@@@@@S * 1@h31MX8 18Hhh3i .i3r ,A@@@@@@@@@5 * ;@&i,58r5 rGSS: :B@@@@@@@@@@A * 1#i . 9i hX. .: .5@@@@@@@@@@@1 * sG1, ,G53s. 9#Xi;hS5 3B@@@@@@@B1 * .h8h.,A@@@MXSs, #@H1: 3ssSSX@1 * s ,@@@@@@@@@@@@Xhi, r#@@X1s9M8 .GA981 * ,. rS8H#@@@@@@@@@@#HG51;. .h31i;9@r .8@@@@BS;i; * .19AXXXAB@@@@@@@@@@@@@@#MHXG893hrX#XGGXM@@@@@@@@@@MS * s@@MM@@@hsX#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&, * :GB@#3G@@Brs ,1GM@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@B, * .hM@@@#@@#MX 51 r;iSGAM@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@8 * :3B@@@@@@@@@@@&9@h :Gs .;sSXH@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@: * s&HA#@@@@@@@@@@@@@@M89A;.8S. ,r3@@@@@@@@@@@@@@@@@@@@@@@@@@@r * ,13B@@@@@@@@@@@@@@@@@@@5 5B3 ;. ;@@@@@@@@@@@@@@@@@@@@@@@@@@@i * 5#@@#&@@@@@@@@@@@@@@@@@@9 .39: ;@@@@@@@@@@@@@@@@@@@@@@@@@@@; * 9@@@X:MM@@@@@@@@@@@@@@@#; ;31. H@@@@@@@@@@@@@@@@@@@@@@@@@@: * SH#@B9.rM@@@@@@@@@@@@@B :. 3@@@@@@@@@@@@@@@@@@@@@@@@@@5 * ,:. 9@@@@@@@@@@@#HB5 .M@@@@@@@@@@@@@@@@@@@@@@@@@B * ,ssirhSM@&1;i19911i,. s@@@@@@@@@@@@@@@@@@@@@@@@@@S * ,,,rHAri1h1rh&@#353Sh: 8@@@@@@@@@@@@@@@@@@@@@@@@@#: * .A3hH@#5S553&@@#h i:i9S #@@@@@@@@@@@@@@@@@@@@@@@@@A. * * * 又看源码,看你妹妹呀! *//*** *_______________#########_______________________ *______________############_____________________ *______________#############____________________ *_____________##__###########___________________ *____________###__######_#####__________________ *____________###_#######___####_________________ *___________###__##########_####________________ *__________####__###########_####_______________ *________#####___###########__#####_____________ *_______######___###_########___#####___________ *_______#####___###___########___######_________ *______######___###__###########___######_______ *_____######___####_##############__######______ *____#######__#####################_#######_____ *____#######__##############################____ *___#######__######_#################_#######___ *___#######__######_######_#########___######___ *___#######____##__######___######_____######___ *___#######________######____#####_____#####____ *____######________#####_____#####_____####_____ *_____#####________####______#####_____###______ *______#####______;###________###______#________ *________##_______####________####______________ *//*** * http://www.vvhan.com/ * .--, .--, * ( ( \.---./ ) ) * '.__/o o\__.' * {= ^ =} * > - < * / \ * // \\ * //| . |\\ * "'\ /'"_.-~^`'-. * \ _ /--' ` * ___)( )(___ * (((__) (__))) 高山仰止,景行行止.虽不能至,心向往之。 *//*** * 这个公司没有年终奖的,兄弟别指望了,也别来了,我准备辞职了 * 另外这个项目有很多*Bug* 你坚持不了多久的,拜拜! *//*** * When I wrote this, only God and I understood what I was doing * Now, God only knows *//*** * 写这段代码的时候,只有上帝和我知道它是干嘛的 * 现在,只有上帝知道 *//*** * 程序员1(于2010年6月7日):在这个坑临时加入一些调料 * 程序员2(于2011年5月22日):临你个屁啊 * 程序员3(于2012年7月23日):楼上都是狗屎,鉴定完毕 * 程序员4(于2013年8月2日):fuck 楼上,三年了,这坑还在!!! * 程序员5(于2014年8月21日):哈哈哈,这坑居然坑了这么多人,幸好我也不用填了,系统终止运行了,you're died *//*** * For the brave souls who get this far: You are the chosen ones, * the valiant knights of programming who toil away, without rest, * fixing our most awful code. To you, true saviors, kings of men, * I say this: never gonna give you up, never gonna let you down, * never gonna run around and desert you. Never gonna make you cry, * never gonna say goodbye. Never gonna tell a lie and hurt you. *//*** * 致终于来到这里的勇敢的人: * 你是被上帝选中的人,是英勇的、不敌辛苦的、不眠不休的来修改我们这最棘手的代码的编程骑士。 * 你,我们的救世主,人中之龙,我要对你说:永远不要放弃,永远不要对自己失望,永远不要逃走,辜负了自己, * 永远不要哭啼,永远不要说再见,永远不要说谎来伤害自己。 *//*** * Dear maintainer: * * Once you are done trying to 'optimize' this routine, * and have realized what a terrible mistake that was, * please increment the following counter as a warning * to the next guy: * * total_hours_wasted_here = 42 *//*** * 亲爱的维护者: * * 如果你尝试了对这段程序进行'优化' * 下面这个计数器的个数用来对后来人进行警告 * * 浪费在这里的总时间 = 42h */// If this comment is removed the program will blow up // 如果删了此处注释程序就炸了
2020年08月26日
2,297 阅读
4 评论
1 点赞
2020-07-20
PHP判断URL的合法性字符串是否为 URL 链接
前言:有好多小伙伴在爬虫的时候,或者其他情况下无法精确判断一个字符串是不是一个标准URL链接地址从而很费脑,下面我么看一下怎么判断URL的合法性。以下代码均为PHP语言代码,但语言都是相通的。第一种:正则表达式<?php function or_url($url){ $preg = "/http[s]?:\/\/[\w.]+[\w\/]*[\w.]*\??[\w=&\+\%]*/is"; if(preg_match($preg,$url)){ echo '正确的 url 地址'; }else{ echo '不是合法的 url 地址'; } }第二种:使用内置函数 filter_var () 推荐<?php function or_url($url){ if (filter_var($url, FILTER_VALIDATE_URL) !== false) { echo 'url 地址正确'; }else{ echo 'url 地址不正确'; } }
2020年07月20日
2,435 阅读
0 评论
1 点赞
2020-03-11
微信扫码登录详解 - 可做登录授权等
可用作微信扫码登录,扫码授权等,自行使用。<?php header('Access-Control-Allow-Origin:*'); header('Content-type:application/json; charset=utf-8'); error_reporting(0); date_default_timezone_set("PRC"); !empty($_GET['type']) ? $type = $_GET['type'] : error("请求参数错误,请刷新重试!~~"); switch ($type) { case 'Getqrcode': echo json_encode(getqrcode()); break; case 'Getresult': !empty($_GET['qrsig']) ? $qrsig=$_GET['qrsig'] : error("请求参数错误,缺少qrsig~~"); echo json_encode(getresult($qrsig),JSON_UNESCAPED_UNICODE); break; default: echo json_encode(getqrcode()); } /** * 获取二维码 */ function getqrcode() { $api = 'https://login.wx2.qq.com/jslogin?appid=wx782c26e4c19acffb'; $ret = get_curl($api); preg_match('/"(.*?)"/', $ret, $matches); $qrcode['data'] = 'https://login.weixin.qq.com/l/'.$matches[1]; $qrcode['uuid'] = $matches[1]; return $qrcode; } /** * @param $qrsig * @return array * 获取登录状态 */ function getresult($uuid) { $paras['ctime'] = 1000; $paras['rtime'] = 1000; $paras['refer'] = 'https://wx2.qq.com/'; $api = 'https://login.wx2.qq.com/cgi-bin/mmwebwx-bin/login?loginicon=true&uuid=' . $uuid . '&tip=0'; $body = get_curl($api, $paras); preg_match('/(\d){3}/', $body, $code); preg_match('/redirect_uri="(.*?)"/', $body, $url); if ($code[0] == '200') { $body = get_curl($url[1]); preg_match('/<wxuin>(\d*?)<\/wxuin>/', $body, $wxuin); $ret['code'] = 200; $ret['data']['uin'] = $wxuin[1]; $ret['data']['type'] = 'wx'; $ret['msg'] = '微信登录成功'; } else { $ret['code'] = 408; $ret['msg'] = '请使用手机微信扫码登录'; } return $ret; } function get_curl($url, $paras = array()) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); $httpheader[] = "Accept:*/*"; $httpheader[] = "Accept-Encoding:gzip,deflate,sdch"; $httpheader[] = "Accept-Language:zh-CN,zh;q=0.8"; $httpheader[] = "Connection:close"; curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader); if ($paras['ctime']) { // 连接超时 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, $paras['ctime']); } if ($paras['rtime']) { // 读取超时 curl_setopt($ch, CURLOPT_TIMEOUT_MS, $paras['rtime']); } if ($paras['post']) { curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $paras['post']); } if ($paras['header']) { curl_setopt($ch, CURLOPT_HEADER, true); } if ($paras['cookie']) { curl_setopt($ch, CURLOPT_COOKIE, $paras['cookie']); } if ($paras['refer']) { if ($paras['refer'] == 1) { curl_setopt($ch, CURLOPT_REFERER, 'http://m.qzone.com/infocenter?g_f='); } else { curl_setopt($ch, CURLOPT_REFERER, $paras['refer']); } } if ($paras['ua']) { curl_setopt($ch, CURLOPT_USERAGENT, $paras['ua']); } else { curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"); } if ($paras['nobody']) { curl_setopt($ch, CURLOPT_NOBODY, 1); } curl_setopt($ch, CURLOPT_ENCODING, "gzip"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $ret = curl_exec($ch); curl_close($ch); return $ret; } function error($str){ exit(json_encode([ "code"=>-1, "msg"=>$str ],JSON_UNESCAPED_UNICODE)); }
2020年03月11日
1,601 阅读
0 评论
0 点赞
2020-03-11
(PHP)Redis Hash(哈希)操作
(PHP)Redis Hash(哈希)操作/** * * Hash操作 * 哈希操作 * 可理解为数据库操作 * */ //为user表中的字段赋值。成功返回1,失败返回0。若user表不存在会先创建表再赋值,若字段已存在会覆盖旧值。 $redis->hSet('user', 'name', '222'); //获取user表中指定字段的值。若user表不存在则返回false。 $redis->hGet('user', 'realname'); //查看user表的某个字段是否存在,存在返回true,否则返回false。 $redis->hExists('user', 'realname'); //删除user表的一个字段,不支持删除多个字段。成功返回1,否则返回0。 $redis->hDel('user', '222'); //同时设置某个user表的多个字段值。成功返回true。 $redis->hMset('user', ['name' => 'jet', 'age' => 18]); //同时获取某个user表的多个字段值。其中不存在的字段值为false。 $redis->hMget('user', ['name', 'age']); //获取某个user表所有的字段和值。 $redis->hGetAll('user'); //获取某个user表所有字段名。user表不存在时返回空数组,key不为user表时返回false。 $redis->hKeys('user'); //获取某个user表所有字段值。 $redis->hVals('user'); //为user表中不存在的字段赋值。若user表不存在则先创建,若字段已存在则不做任何操作。设置成功返回true,否则返回false。 $redis->hSetNx('user', 'realname', 'jetwu'); //获取某个user表的字段数量。若user表不存在返回0,若user不是hash表则返回false。 $redis->hLen('user'); //为user表中的指定字段加上指定的数值,若user表不存在则先创建,若字段不存在则先初始化值为0再进行操作,若字段值为字符串则返回false。设置成功返回字段新值。 $redis->hIncrBy('user', 'age', 10); //为user表中的指定字段加上指定浮点数值。 $redis->hIncrBy('user', 'age', 1.5);
2020年03月11日
1,458 阅读
0 评论
0 点赞
2020-03-11
PHP中include,require,include_once,require_once的区别详解
前言在做程序设计的时候避免不了要去引用外部文件,在 PHP 中引入文件的方式有很多种,这里详细说一下 include ;require ;include_once;require_once。`require ()` 语句的性能与 `include ()` 相类似,都是包括并运行指定文件。除了处理失败的方式不同之外。`require` 在出错时产生 `E_COMPILE_ERROR` 级别的错误,终止脚本运行;而 `include` 只产生警告`(E_WARNING)`,脚本会继续运行。1.include 和 require 都是语句结构(并不是函数)在 php 官网手册上是划分到了流程控制,这两个语句结构不是函数。详情可参考 http://php.net/manual/zh/function.include.php所以,它可以不加圆括号,直接加引号来包含文件。我习惯不加圆括号。include '01_var.php'; 或者 include('01_var.php'); 或者 require '01_var.php'; 或者 require('01_var.php');2. 对于处理失败的方式不同(最主要的区别)对于引入的文件找不到情况下。(这里确保当前文件夹下面不存在 no.php)在 01_include_require 文件下编写如下代码:include 'no.php'; echo 'End!';//会输出include 生成一个警告(E_WARNING),在错误发生后脚本会继续执行。require 'no.php'; echo 'End!';//不会输出require 生成一个致命错误(E_COMPILE_ERROR),在错误发生后脚本会停止执行。3. 对 include 和 require 引入文件的实质对 include () 语句来说,在执行文件时每次都要进行读取和评估;对于 require () 来说,文件只处理一次(实际上,文件内容替换 require () 语句)这就意味着如果可能执行多次的代码,则使用require () 效率比较高。另外一方面,如果每次执行代码时是读取不同的文件,或者有通过一组文件迭代的循环,就使用 include () 语句。4.include_once 和 require_once 的作用使用方法与不加后缀一样,加上_once 后缀 意味着如果该文件中的代码已经被包括进来了,就不会再次包括。因为有些情况下,在脚本执行期间,同一个文件有可能包含超过一次的情况下,为了确保只包含一次,避免函数重定义,或者是变量的重新赋值的问题。include_once '01_var.php'; require_once '01_var.php';使用场景如果您希望继续执行,并向用户输出结果,即使包含文件已丢失,那么请使用 include。在框架复杂的 php 应用程序编程中,请始终使用 require向执行流引用关键文件。这有助于提高应用程序的安全性和完整性,在某个关键文件意外丢失的情况下。包含文件省去了大量的工作。例如在 thinkphp 框架 index 入口引入核心代码就是利用 require 引入的。require 通常放在 php 脚本程序最前面,php 再执行程序前,就会先读取 require语句引入的文件,使之成为 php 脚本文件的一部分。include 通常用在流程控制的处理部分中,php 脚本在读到 include的文件时,才将它读进来。这种方式,可以把程序执行时的流程简单化。
2020年03月11日
1,095 阅读
0 评论
0 点赞
1
2
3