jquery.pjax.js
history.state
history.pushState
history.replaceState
CSS控制打印时内容
@media print{ /*以下为打印时载入的CSS代码*/ .banner, .sidebar{display:none;} #wrapper, .main{clear:both;width:100% !important;height:auto !important;} }
CSS3 线性渐变(linear-gradient),半透明+渐变
1、开始于center(水平方向)和top(垂直方向)也就是Top → Bottom: /* Firefox 3.6+ */ background-image:-moz-linear-gradient(top, #ace, #f96); /* Safari 5.1+, Chrome 10+ */ background-image:-webkit-linear-gradient(top, #ace, #f96); /* Opera 11.10+ */ background-image:-o-linear-gradient(top, #ace, #f96); 2、始于left(水平方向)和center(垂直方向)也是就Left → Right: /* Firefox 3.6+ */ background-image: -moz-linear-gradient(left, #ace, #f96); /* Safari 5.1+, Chrome 10+ */ background-image: -webkit-linear-gradient(left, #ace, #f96); /* Opera 11.10+ */ background-image: -o-linear-gradient(left, #ace, #f96); 3、起始于left(水平方向)和top(垂直方向): background-image: -moz-linear-gradient(left top, #ace, #f96); background-image: -webkit-linear-gradient(left top, #ace, #f96); background-image: -o-linear-gradient(left top, #ace, #f96); 4、角度(Angle): .deg45 { background-image: -moz-linear-gradient(45deg, #ace, #f96); background-image: -webkit-linear-gradient(45deg, #ace, #f96); background-image: -o-linear-gradient(45deg, #ace, #f96); }
5、变透明+渐变 div{ background-image:linear-gradient( to bottom, rgba(0,0,0,.6) 0%, rgba(0,0,0,.3) 50%, rgba(0,0,0,0) 100% ); background-image:-webkit-linear-gradient( bottom, rgba(0,0,0,.6) 0%, rgba(0,0,0,.3) 50%, rgba(0,0,0,0) 100% ); }
rgba(0,0,0,0) 50%
rgba(0,0,0,0) 50%
rgba(0,0,0,.6) 0%,
jq获取iframe加载完后的数据并格式化
var txt=$($(this)[0].contentWindow.document.body).text(), flag=true;
try{
txt=eval('('+txt+')');
}catch(e){
flag=false;
}
json=flag ? txt : false;
});
身份证号码验证
var card=idcard;
//是否为空
if(card === '') {
return false;
}
//校验长度,类型
if(/(^\d{15}$)|(^\d{17}(\d|X)$)/i.test(card) === false) {
return false;
}
var arrInt = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2], arrCh = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'], cardTemp=0, i=0;
//15位升18位
if(card.length==15){
card = card.substr(0, 6) + '19' + card.substr(6);
for(i = 0; i < 17; i ++) {
cardTemp += card.substr(i, 1) * arrInt[i];
}
card += arrCh[cardTemp % 11];
}
//省份验证
var vcity = {
11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",
21:"辽宁",22:"吉林",23:"黑龙江",31:"上海",32:"江苏",
33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",
41:"河南",42:"湖北",43:"湖南",44:"广东",45:"广西",
46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",
54:"西藏",61:"陕西",62:"甘肃",63:"青海",64:"宁夏",
65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外"
};
if(vcity[card.substr(0,2)] == undefined) {
return false;
}
//校验生日
var arr=[card.substr(6,4), card.substr(10,2), card.substr(12,2)];
arr.push(new Date(arr.join('-')));
arr.push(new Date().getFullYear());
if(arr[3].getFullYear()==arr[0] && (arr[3].getMonth()+1)==arr[1] && arr[3].getDate()==arr[2]){
//年龄0-120岁
if(arr[4]-arr[0]<0 || arr[4]-arr[0]>120){
return false;
}
}else{
return false;
}
if(idcard.length==15)return true;
for(i = 0; i < 17; i ++) {
cardTemp += card.substr(i, 1) * arrInt[i];
}
return arrCh[cardTemp % 11] == card.substr(17, 1)
};
好久不见-WXL
请输入查看密码:PHP函数用法
1、string number_format ( float $number , int $decimals = 0 , string $dec_point = "." , string $thousands_sep = "," )
本函数可以接受1个、2个或者4个参数(注意:不能是3个):
2、int strtotime(string $time [, int $now = time() ])
时间运算
<?php echo strtotime("now"), "\n"; echo strtotime("10 September 2000"), "\n"; echo strtotime("+1 day 2010-01-01 12:20:25"), "\n"; echo strtotime("+1 day"), "\n"; echo strtotime("+1 week"), "\n"; echo strtotime("+1 week 2 days 4 hours 2 seconds"), "\n"; echo strtotime("next Thursday"), "\n"; echo strtotime("last Monday"), "\n"; ?>
3、
file_get_contents ( string $filename [, bool $use_include_path = false [, resource $context [, int $offset = -1 [, int$maxlen ]]]] ) : string
把文件读入一个字符串。将在参数 offset 所指定的位置开始读取长度为 maxlen 的内容。如果失败,file_get_contents() 将返回 FALSE。
file_get_contents() 函数是用来将文件的内容读入到一个字符串中的首选方法。
如果操作系统支持还会使用内存映射技术来增强性能。如果要打开有特殊字符的 URL (比如说有空格),就需要使用 urlencode() 进行 URL 编码。
设置 file_get_contents() 的超时时间:
//设置超时参数 $opts=array( "http"=>array( "method"=>"GET", "timeout"=>3 ), ); ////创建数据流上下文 $context = stream_context_create($opts); //$url请求的地址,例如: $result =file_get_contents($url, false, $context);
//伪造header,可用于fopen/file_get_contents //个别网站伪造referer反而打不开图片,如 https://mmbiz.qlogo.cn/mmbiz_jpg/lpbWiblialBFNfHKQM7hLhCW2f4QwVYHGhxxHa6ZHjS6IcAd0yBG9FpX4qINm2bJ7AhQdyQbibQIQ6juCUcfLiaZMA/0?wx_fmt=jpeg $opts = array( 'http' => array( 'header' => "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36\r\n". Referer: ".($source_parse_url['scheme'].'://'.$source_parse_url['host'].$source_parse_url['path'])."\r\n", ), ); $context = stream_context_create($opts); $result =file_get_contents($url, false, $context);
更多参考: https://www.cnblogs.com/Renyi-Fan/p/9642301.html
4、iconv ( string $in_charset , string $out_charset , string $str ) 把字符串按要求的字符编码来转换
如果你在 out_charset 后添加了字符串 //TRANSLIT,将启用转写(transliteration)功能。这个意思是,当一个字符不能被目标字符集所表示时,它可以通过一个或多个形似的字符来近似表达。 如果你添加了字符串 //IGNORE,不能以目标字符集表达的字符将被默默丢弃。 否则,会导致一个 E_NOTICE并返回 FALSE。
iconv("utf-8","gbk//TRANSLIT",$str); //utf-8转gbk iconv("utf-8","gbk//IGNORE",$str); iconv("utf-8","gbk",$str); iconv("gbk","utf-8",$str); //gbk转utf-8