金光 发表于 2005 年 10 月 8 日 15:42:20

php通用检测函数集(5)

// 函数名:AlertExit($C_alert,$I_goback=0) // 作 用:非法操作警告 // 参 数:$C_alert(提示的错误信息) //
$I_goback(返回到那一页) // 返回值:字符串 // 备 注:无
//----------------------------------------------------------------------------------- ------- function AlertExit
($C_alert,$I_goback=0) { if($I_goback0) { echo alert('$C_alert');history.go($I_goback);; exit; } else { echo
alert('$C_alert');; exit; } }
//----------------------------------------------------------------------------------- -------
//----------------------------------------------------------------------------------- ------- // 函数名:
ReplaceSpacialChar($C_char) // 作 用:特殊字符替换函数 // 参 数:$C_char(待替换的字符串) // 返回值:字符串 //
备 注:无 //----------------------------------------------------------------------------------- ------- function
ReplaceSpecialChar($C_char) { $C_char=HTMLSpecialChars($C_char); //将特殊字元转成 HTML 格式。 $C_char=nl2br
($C_char); //将回车替换为 $C_char=str_replace( , ,$C_char); //替换空格替换为 $C_char=str_replace(
$char='¥5,645,132.31' //-----------------------------------------------------------------------------------
------- function ExchangeMoney($N_money) { $A_tmp=explode(.,$N_money ); //将数字按小数点分成两部分,并存入数组
$A_tmp $I_len=strlen($A_tmp); //测出小数点前面位数的宽度 if($I_len%3==0) { $I_step=$I_len/3; //如前面位数的宽
度mod 3 = 0 ,可按,分成$I_step 部分 }else { $step=($len-$len%3)/3+1; //如前面位数的宽度mod 3 != 0 ,可按,分成
$I_step 部分+1 } $C_cur=; //对小数点以前的金额数字进行转换 while($I_len0) { $I_step--; if($I_step==0) { $C_cur .=
substr($A_tmp,0,$I_len-($I_step)*3); }else { $C_cur .= substr($A_tmp,0,$I_len-($I_step)*3).,; } $A_tmp
=substr($A_tmp,$I_len-($I_step)*3); $I_len=strlen($A_tmp); } //对小数点后面的金额的进行转换 if($A_tmp==)
{ $C_cur .= .00; }else { $I_len=strlen($A_tmp); if($I_len ){$C_target=window.location='$C_url?
$C_getOther='+this.value;} if($C_get   && $C_getOther == ){$C_target=window.location='$C_url? $C_get';} if($C_get  
&& $C_getOther){$C_target=window.location='$C_url? $C_get&$C_getOther='+this.value;} return $C_target; }
//----------------------------------------------------------------------------------- ----- ?>


转自:http://edu.chinaz.com

金光 发表于 2005 年 10 月 8 日 15:42:20

php通用检测函数集(5)

// 函数名:AlertExit($C_alert,$I_goback=0) // 作 用:非法操作警告 // 参 数:$C_alert(提示的错误信息) //
$I_goback(返回到那一页) // 返回值:字符串 // 备 注:无
//----------------------------------------------------------------------------------- ------- function AlertExit
($C_alert,$I_goback=0) { if($I_goback0) { echo alert('$C_alert');history.go($I_goback);; exit; } else { echo
alert('$C_alert');; exit; } }
//----------------------------------------------------------------------------------- -------
//----------------------------------------------------------------------------------- ------- // 函数名:
ReplaceSpacialChar($C_char) // 作 用:特殊字符替换函数 // 参 数:$C_char(待替换的字符串) // 返回值:字符串 //
备 注:无 //----------------------------------------------------------------------------------- ------- function
ReplaceSpecialChar($C_char) { $C_char=HTMLSpecialChars($C_char); //将特殊字元转成 HTML 格式。 $C_char=nl2br
($C_char); //将回车替换为 $C_char=str_replace( , ,$C_char); //替换空格替换为 $C_char=str_replace(
$char='¥5,645,132.31' //-----------------------------------------------------------------------------------
------- function ExchangeMoney($N_money) { $A_tmp=explode(.,$N_money ); //将数字按小数点分成两部分,并存入数组
$A_tmp $I_len=strlen($A_tmp); //测出小数点前面位数的宽度 if($I_len%3==0) { $I_step=$I_len/3; //如前面位数的宽
度mod 3 = 0 ,可按,分成$I_step 部分 }else { $step=($len-$len%3)/3+1; //如前面位数的宽度mod 3 != 0 ,可按,分成
$I_step 部分+1 } $C_cur=; //对小数点以前的金额数字进行转换 while($I_len0) { $I_step--; if($I_step==0) { $C_cur .=
substr($A_tmp,0,$I_len-($I_step)*3); }else { $C_cur .= substr($A_tmp,0,$I_len-($I_step)*3).,; } $A_tmp
=substr($A_tmp,$I_len-($I_step)*3); $I_len=strlen($A_tmp); } //对小数点后面的金额的进行转换 if($A_tmp==)
{ $C_cur .= .00; }else { $I_len=strlen($A_tmp); if($I_len ){$C_target=window.location='$C_url?
$C_getOther='+this.value;} if($C_get   && $C_getOther == ){$C_target=window.location='$C_url? $C_get';} if($C_get  
&& $C_getOther){$C_target=window.location='$C_url? $C_get&$C_getOther='+this.value;} return $C_target; }
//----------------------------------------------------------------------------------- ----- ?>


转自:http://edu.chinaz.com
页: [1]
查看完整版本: php通用检测函数集(5)