PHP头条
热点:

php 字符串检查类


*
 字符串检查类
 *@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<$min)?false:true;
 }
 /*
 信息处理,跳转到页面
 @param $page     跳转到的页面   
 @param $msg      提示信息
 */
 function msg($page,$msg)
 {
  $msg = empty($msg)?'''''''':"?msg=".base64_encode($msg);
  $url=$page.$msg;
  if(@header("Location:".$url))
  {
     echo "<meta http-equiv=refresh content=''''0;url=".$url."''''>";
  }
  exit();
 }
 
}

 

www.phpzy.comtrue/php/5448.htmlTechArticlephp 字符串检查类 * 字符串检查类 *@author sanshi QQ:35047205 Email:sanshi0815@tom.com MSN:sanshi0815@tom.com */ class checkBase { function checkBase() { } /* 用来检查字符串是否为空 *@param $str 检查的字段 *@param...

相关文章

    暂无相关文章
相关频道:

PHP之友评论

今天推荐