search
Homephp教程php手册php通用检测函数集(5)

php通用检测函数集(5)

Jun 13, 2016 am 10:20 AM
alertphpfunctionoperatenumberDetectionusewarnUniversal

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


//-----------------------------------------------------------------------------------
-------
// 函数名:ExchangeMoney($N_money)
// 作 用:资金转换函数
// 参 数:$N_money(待转换的金额数字)
// 返回值:字符串
// 备 注:本函数示例:$char=ExchangeMoney(5645132.3155) ==>
$char=¥5,645,132.31
//-----------------------------------------------------------------------------------
-------
function ExchangeMoney($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; //如前面位数的宽度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],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{
$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_get GET方法参数
// $C_getOther GET方法的其他参数
// 返回值: 字符串
// 备 注:无
//-----------------------------------------------------------------------------------
-----
function WindowLocation($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;
}
//-----------------------------------------------------------------------------------
-----

?>  

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools