Home > php教程 > php手册 > body text

php 字符串检查类

WBOY
Release: 2016-06-13 10:11:22
Original
779 people have browsed it

*
 字符串检查类
 *@author  sanshi
    QQ:35047205
    Email:sanshi0815@tom.com
    MSN:sanshi0815@tom.com

*/
class checkBase
{
 function checkBase()
 {
 }
 /*
 用来检查字符串是否为空
 *@param $str 检查的字段
 *@param $isStr 如果字段有可能唯一字符是数字或者bool类型时使用
 为空的时候返回true
 */
 function strIsNull($str,$isStr=true)
 {
  return $isStr?(empty($str)?true:false)
      :(isset($str)?false:true);
 }
 /*
 字符串与正则表达式做比较
 @param $str   要比较的字符串
 @param $pattern     要比对的正则
 与正则比对上了返回true
 */
 function strComparePattern($str,$pattern)
 {
  if(ereg($pattern,$str))
  {
   //找到了返回
   return true;
  }
  return false;
 }
 /*
 判断字符串长短
 @param $str 要检查的字符串
 @param $max 最大长度
 @param $min 最小长度
 符合要求返回true
 */
 function strCompareLen($str,$max,$min=1)
 {
  $len = strlen($str);
  $max=empty($max)?$len:$max;
  return ($len>$max || $len  }
 /*
 信息处理,跳转到页面
 @param $page     跳转到的页面   
 @param $msg      提示信息
 */
 function msg($page,$msg)
 {
  $msg = empty($msg)?'''''''':"?msg=".base64_encode($msg);
  $url=$page.$msg;
  if(@header("Location:".$url))
  {
     echo "";
  }
  exit();
 }
 
}

 

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!