This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$url = 'http://baidu.com'; | |
$opts = array( | |
'http' =>array( | |
'method' => 'GET', | |
'header' => "Connection: keep-alive\r\n". | |
"Upgrade-Insecure-Requests: 1\r\n". | |
"User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36\r\n". | |
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8\r\n". | |
"Accept-Encoding: gzip, deflate\r\n". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
注意邮件字母全小写 验证的时候提前转换下 | |
/^[a-z\d]+([-_.][a-z\d]+)*@[a-z\d]+([-.][a-z\d]+)*\.[a-z]{2,5}$/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{"code":"110000","sheng":"11","di":"00","xian":"00","name":"北京市","level":1},{"code":"110100","sheng":"11","di":"01","xian":"00","name":"市辖区","level":2},{"code":"110101","sheng":"11","di":"01","xian":"01","name":"东城区","level":3},{"code":"110102","sheng":"11","di":"01","xian":"02","name":"西城区","level":3},{"code":"110105","sheng":"11","di":"01","xian":"05","name":"朝阳区","level":3},{"code":"110106","sheng":"11","di":"01","xian":"06","name":"丰台区","level":3},{"code":"110107","sheng":"11","di":"01","xian":"07","name":"石景山区","level":3},{"code":"110108","sheng":"11","di":"01","xian":"08","name":"海淀区","level":3},{"code":"110109","sheng":"11","di":"01","xian":"09","name":"门头沟区","level":3},{"code":"110111","sheng":"11","di":"01","xian":"11","name":"房山区","level":3},{"code":"110112","sheng":"11","di":"01","xian":"12","name":"通州区","level":3},{"code":"110113","sheng":"11","di":"01","xian":"13","name":"顺义区","level":3},{"code":"110114","sheng":"11","di":"01","xian":"14","name":"昌平区","level":3},{"code":"110115","sheng":"11","di |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// 指定日期上个月的第一天 | |
echo date_create('2016-01-28 first day of last month')->format('Y-m-d'),'<br>'; | |
echo date('Y-m-d', strtotime('2016-01-28 first day of last month')),'<br>'; | |
echo date('Y-m-d', strtotime('first day of last month', strtotime('2016-01-28'))),'<br><br>'; | |
// 这个月的第一天 | |
echo date('Y-m-d', strtotime('first day of this month')),'<br>'; | |
// 下个月的最后一天 | |
echo date('Y-m-d', strtotime('last day of +1 month')),'<br>'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function idcard_check(id) | |
{ | |
if(!/^\d{18}$|^\d{17}X$/.test(id)) return false; | |
var code = [1,0,'X',9,8,7,6,5,4,3,2]; | |
var sum = 0; | |
for(var i=17; i>0; i--){ | |
sum += id[17-i] * Math.pow(2,i)%11; | |
} | |
return id[17]==code[sum%11]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
国内手机号码是由11位数字组成 1开头 3,4,5,7,8 分别分配给不同运营商 | |
还有未分配的号段 如 172xxxxxxxx | |
精力有限只管前3位(截止到2016.1) | |
/^((1[3,5,8][0-9])|(14[5,7])|(17[0,1,6,7,8]))\d{8}$/ | |
或者偷懒只管前2位(10,11,12,16,19都是特殊号段 如110,120,114 eg.) | |
/^1[3,4,5,7,8]\d{9}$/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |