//是否為空白 function isempt($str) { $bool=false; if( ($str==''||$str==NULL||empty($str)) && (!is_numeric($str)) )$bool=true; return $bool; } //是否包含 function contain($str,$a) { $bool=false; if(!isempt($a) && !isempt($str)){ $ad=strpos($str,$a); if($ad>0||!is_bool($ad))$bool=true; } return $bool; } //是否是ajax function isajax() { if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH'])=='xmlhttprequest'){ return true; }else{ return false; }; }//是否為郵箱public function isemail($str){if(isempt($str))return false;return filter_var($str, FILTER_VALIDATE_EMAIL);}//是否為手機號public function ismobile($str){if(isempt($str))return false;if(!is_numeric($str) || strlen($str)!=11)return false;return true;}//是否有中文public function isincn($str){return preg_match("/[\x7f-\xff]/", $str);}//是否整個的英文a-z,0-9public function iszgen($str){if(isempt($str))return false;if($this->isincn($str)){return false;}return true;}//返回字串編碼public function getencode($str){$encode = mb_detect_encoding($str, array('ASCII','UTF-8','GB2312','GBK','BIG5'));$encode = strtolower($encode);return $encode;}//是否為數字public function isnumber($str){if(isempt($str))return false;return is_numeric($str);}