Hello World - 2018年2月
type: channel
link: https://mww.njfengwei.cn/index.php/2018/02/
description: Your description here.
items: curl发送https的请求（POST）
items: PHP 判断是手机还是电脑在访问
items: 获取汉字英语繁体首字母
items: js正则：小数位可有可无，最多两位小数，必须大于零

curl发送https的请求（POST）
type: item
date: 2018-02-28T15:09:00+08:00
description: 这是云之讯发送的短信验证码，https的请求（POST发送）$body_json = array( 'sid'=>'', 'token'=>'', 'appid'=>'', 'templateid'=>'271253', 'param'=>$num, 'mobile'=>$phone, 'uid'=>'', ); $body = json_encode($body_json); $header = array( 'Accept:application/json', 'Content-Type:application/json;charset=utf-8', ); $url = 'https://open.ucpaas.com/ol/sms/sendsms'; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch,CURLOPT_POST,1); curl_setopt($ch,CURLOPT_POSTFIELDS,$body); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); $result = curl_exec($ch); curl_close($ch); $res = json_decode($result,true); return $res;

PHP 判断是手机还是电脑在访问
type: item
date: 2018-02-02T11:59:57+08:00
description: public function ismobile() { // 如果有HTTP_X_WAP_PROFILE则一定是移动设备 if (isset ($_SERVER['HTTP_X_WAP_PROFILE'])) return true; //此条摘自TPM智能切换模板引擎，适合TPM开发 if(isset ($_SERVER['HTTP_CLIENT']) &&'PhoneClient'==$_SERVER['HTTP_CLIENT']) return true; //如果via信息含有wap则一定是移动设备,部分服务商会屏蔽该信息 if (isset ($_SERVER['HTTP_VIA'])) //找不到为flase,否则为true return stristr($_SERVER['HTTP_VIA'], 'wap') ? true : false; //判断手机发送的客户端标志,兼容性有待提高 if (isset ($_SERVER['HTTP_USER_AGENT'])) { $clientkeywords = array( 'nokia','sony','ericsson','mot','samsung','htc','sgh','lg','sharp','sie-','philips','panasonic','alcatel','lenovo','iphone','ipod','blackberry','meizu','android','netfront','symbian','ucweb','windowsce','palm','operamini','operamobi','openwave','nexusone','cldc','midp','wap','mobile' ); //从HTTP_USER_AGENT中查找手机浏览器的关键字 if (preg_match("/(" . implode('|', $clientkeywords) . ")/i", strtolower($_SERVER['HTTP_USER_AGENT']))) { return true; } } //协议法，因为有可能不准确，放到最后判断 if (isset ($_SERVER['HTTP_ACCEPT'])) { // 如果只支持wml并且不支持html那一定是移动设备 // 如果支持wml和html但是wml在html之前则是移动设备 if ((strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') !== false) && (strpos($_SERVER['HTTP_ACCEPT'], 'text/html') === false || (strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') < strpos($_SERVER['HTTP_ACCEPT'], 'text/html')))) { return true; } } return false; }

获取汉字英语繁体首字母
type: item
date: 2018-02-02T11:48:32+08:00
description: js文件（写入js文件引入即可）var charset={ isChinese:function (str){ //判断第一个字符是中英文 var cnChar=str.match(/[\u4e00-\u9fff]/g); if(cnChar!=null&&cnChar.length>0){ return true; } else{ return false; } }, isEnglish:function(str){//判断第一个字母是不是英文 var cnChar=str.match(/[a-zA-Z]/g); if(cnChar!=null&&cnChar.length>0){ return true; } else{ return false; } }, toPinyin:function (str){//汉字获取拼音首字母 var strChineseFirstPY = "YDYQSXMWZSSXJBYMGCCZQPSSQBYCDSCDQLDYLYBSSJGYZZJJFKCCLZDHWDWZJLJPFYYNWJJTMYHZWZHFLZPPQHGSCYYYNJQYXXGJHHSDSJNKKTMOMLCRXYPSNQSECCQZGGLLYJLMYZZSECYKYYHQWJSSGGYXYZYJWWKDJHYCHMYXJTLXJYQBYXZLDWRDJRWYSRLDZJPCBZJJBRCFTLECZSTZFXXZHTRQHYBDLYCZSSYMMRFMYQZPWWJJYFCRWFDFZQPYDDWYXKYJAWJFFXYPSFTZYHHYZYSWCJYXSCLCXXWZZXNBGNNXBXLZSZSBSGPYSYZDHMDZBQBZCWDZZYYTZHBTSYYBZGNTNXQYWQSKBPHHLXGYBFMJEBJHHGQTJCYS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HLYYYSDZPAQYZCMTLSHTZCFYZYXYLJSDCJQAGYSLCQLYYYSHMRQQKLDXZSCSSSYDYCJYSFSJBFRSSZQSBXXPXJYSDRCKGJLGDKZJZBDKTCSYQPYHSTCLDJDHMXMCGXYZHJDDTMHLTXZXYLYMOHYJCLTYFBQQXPFBDFHHTKSQHZYYWCNXXCRWHOWGYJL…

js正则：小数位可有可无，最多两位小数，必须大于零
type: item
date: 2018-02-01T22:41:00+08:00
description: 可以是零点几几//如果是限制5位小数，就是{1,5}; /^\d+(?:\.\d{1,2})?$/