当前位置: 首页 > 图文教程 > 网络编程 > PHP > php通用检测函数集(5)

PHP
MySQL手册版本 5.0.20-MySQL优化(四) (1)(3)
MySQL手册版本 5.0.20-MySQL优化(四) (1)(2)
Navicat MySQL图形客户端mac新版发布
MySQL手册版本 5.0.20-MySQL优化(四) (1)
MySQL手册版本 5.0.20-MySQL优化(二) (1)(4)
MySQL手册版本 5.0.20-MySQL优化(二) (1)(3)
MySQL手册版本 5.0.20-MySQL优化(二) (1)(2)
MySQL手册版本 5.0.20-MySQL优化(二) (1)
经验总结:mysql 的一些基本应用
如何在Windows上配置并整合PHP和MySQL(1)
如何在Windows上配置并整合PHP和MySQL(2)
程序员最容易犯的五个PHP数据库问题及解释
如何利用MySQL加密函数保护Web网站敏感数据
SQL Server日志文件总结及充满处理方式
用Apache Geronimo创建并部署blog和wiki 模块
对SQL数据库定期进行收缩 减小日志存储压力
从4.0到5.1 为什么MySQL却被冠名"玩具数据库"
在数据库中 如何进行分类分组并总计SQL信息
深入浅出举例应用 SQL数据库使用系列
实例:用触发器生成数据库表的数据操作日志

PHP 中的 php通用检测函数集(5)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 65 ::
收藏到网摘: n/a

//函数名:AlertExit($C_alert,$I_goback=0)
//作用:非法操作警告
//参数:$C_alert(提示的错误信息)
//$I_goback(返回到那一页)
//返回值:字符串
//备注:无
//-----------------------------------------------------------------------------------
-------
functionAlertExit($C_alert,$I_goback=0)
{
if($I_goback<>0)
{
echo"<script>alert('$C_alert');history.go($I_goback);</script>";
exit;
}
else
{
echo"<script>alert('$C_alert');</script>";
exit;
}
}
//-----------------------------------------------------------------------------------
-------


//-----------------------------------------------------------------------------------
-------
//函数名:ReplaceSpacialChar($C_char)
//作用:特殊字符替换函数
//参数:$C_char(待替换的字符串)
//返回值:字符串
//备注:无
//-----------------------------------------------------------------------------------
-------
functionReplaceSpecialChar($C_char)
{
$C_char=HTMLSpecialChars($C_char);//将特殊字元转成HTML格式。
$C_char=nl2br($C_char);//将回车替换为<br>
$C_char=str_replace("","",$C_char);//替换空格替换为
$C_char=str_replace("<?","<?",$C_char);//替换PHP标记
return$C_char;
}
//-----------------------------------------------------------------------------------
-------


//-----------------------------------------------------------------------------------
-------
//函数名:ExchangeMoney($N_money)
//作用:资金转换函数
//参数:$N_money(待转换的金额数字)
//返回值:字符串
//备注:本函数示例:$char=ExchangeMoney(5645132.3155)==>
$char='¥5,645,132.31'
//-----------------------------------------------------------------------------------
-------
functionExchangeMoney($N_money)
{
$A_tmp=explode(".",$N_money);//将数字按小数点分成两部分,并存入数组$A_tmp
$I_len=strlen($A_tmp[0]);//测出小数点前面位数的宽度

if($I_len%3==0)
{
$I_step=$I_len/3;//如前面位数的宽度mod3=0,可按,分成$I_step
部分
}else
{
$step=($len-$len%3)/3+1;//如前面位数的宽度mod3!=0,可按,分成$I_step
部分+1
}

$C_cur="";
//对小数点以前的金额数字进行转换
while($I_len<>0)
{
$I_step--;

if($I_step==0)
{
$C_cur.=substr($A_tmp[0],0,$I_len-($I_step)*3);
}else
{
$C_cur.=substr($A_tmp[0],0,$I_len-($I_step)*3).",";
}

$A_tmp[0]=substr($A_tmp[0],$I_len-($I_step)*3);
$I_len=strlen($A_tmp[0]);
}

//对小数点后面的金额的进行转换
if($A_tmp[1]=="")
{
$C_cur.=".00";
}else
{
$I_len=strlen($A_tmp[1]);
if($I_len<2)
{
$C_cur.=".".$A_tmp[1]."0";
}else
{
$C_cur.=".".substr($A_tmp[1],0,2);
}
}

//加上人民币符号并传出
$C_cur="¥".$C_cur;
return$C_cur;
}
//-----------------------------------------------------------------------------------
-------


//-----------------------------------------------------------------------------------
------
//函数名:WindowLocation($C_url,$C_get="",$C_getOther="")
//作用:PHP中的window.location函数
//参数:$C_url转向窗口的URL
//$C_getGET方法参数
//$C_getOtherGET方法的其他参数
//返回值:字符串
//备注:无
//-----------------------------------------------------------------------------------
-----
functionWindowLocation($C_url,$C_get="",$C_getOther="")
{
if($C_get==""&&$C_getOther=="")
if($C_get==""&&$C_getOther<>""){$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;
}
//-----------------------------------------------------------------------------------
-----

?>

'