<?php
/* 字符串处理类
* 参数$length用作判断字符串是否超过指定长度
* 转义 SQL 语句中使用的字符串中的特殊字符
* 正则限制字符串内只能为数字
* 判断字符串是否为空
* 判断字符串长度
*/
// 创建字符串处理类
class StringFiltration {
// 属性
var $length;
// 方法
// 构造方法
function __construct($the_length = NULL){
$this->length = $the_length;
}
// 转义 SQL 语句中使用的字符串中的特殊字符
function realEscapeString($the_string){
return mysql_real_escape_string($the_string);
}
// 正则限制字符串内只能为数字
function eregNumber($the_string){
if( ereg("^[0-9]+$",$the_string) )
return true;
else
return false;
}
// 判断字符串是否为空
function strlenString($the_string){
return strlen($the_string);
}
// 判断字符串长度
function ifOverStrlenLength($the_string){
if( strlen($the_string) > $this->length )
return true;
else
return false;
}
}
?>
$string = new StringFiltration();
$email = $string->realEscapeString($_POST['email']); $postId = $string->eregNumber($id);
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有