Home > Backend Development > PHP Tutorial > PHP general detection function set (5)_PHP tutorial

PHP general detection function set (5)_PHP tutorial

WBOY
Release: 2016-07-13 17:19:57
Original
888 people have browsed it

// Function name: AlertExit($C_alert,$I_goback=0)
// Function: Illegal operation warning
// Parameter: $C_alert (error message prompted)
// $I_goback (return to That page)
// Return value: String
// Remarks: None
//----------------------- -------------------------------------------------- ----------
-------
function AlertExit($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;
}
}
//--------- -------------------------------------------------- --------------------------
------


//----- -------------------------------------------------- ----------------------------
-------
// Function name: ReplaceSpacialChar($C_char )
// Function: Special character replacement function
// Parameter: $C_char (string to be replaced)
// Return value: String
// Remarks: None
/ /------------------------------------------------- ----------------------------------
-------
function ReplaceSpecialChar( $C_char)
{
$C_char=HTMLSpecialChars($C_char); //Convert special characters into HTML format.
$C_char=nl2br($C_char); //Replace carriage return with

$C_char=str_replace(" "," ",$C_char); //Replace spaces with
$C_char=str_replace("return $C_char;
}
//-------- -------------------------------------------------- --------------------------
-------


//---- -------------------------------------------------- --------------------------
-------
// Function name: ExchangeMoney($ N_money)
// Function: Fund conversion function
// Parameter: $N_money (amount to be converted)
// Return value: String
// Note: Example of this function: $ char=ExchangeMoney(5645132.3155) ==>
$char=¥5,645,132.31
//-------------------------- -------------------------------------------------- ------
-------
function ExchangeMoney($N_money)
{
$A_tmp=explode(".",$N_money ); //Press the number The decimal point is divided into two parts and stored in the array $A_tmp
$I_len=strlen($A_tmp[0]); //Measure the width of the digits in front of the decimal point

if($I_len%3== 0)
{
$I_step=$I_len/3; //If the width of the previous digits mod 3 = 0, it can be divided into $I_step
part
}else
{
$step=($len-$len%3)/3+1; //If the width of the previous digits mod 3 != 0, it can be divided into $I_step
part+1
}

$C_cur="";
//Convert the amount before the decimal point
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]);
}

//After the decimal point Convert the amount
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);
}
}

//Add RMB symbol and transmit out
$C_cur="¥".$C_cur;
return $C_cur;
}
//----------------------------- -------------------------------------------------- -------------
------


//---------------- -------------------------------------------------- ------------------
------
// Function name: WindowLocation($C_url,$C_get="",$C_getOther="" )
// Function: window.location function in PHP
// Parameters: $C_url URL of the steering window
// $C_get GET method parameters
// $C_getOther Other parameters of the GET method
// Return value: String
// Remarks: None
//-------------------------- -------------------------------------------------- ------
-----
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;
}
//--------------------------------- --------------------------------------------------
-----

?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532628.htmlTechArticle// Function name: AlertExit($C_alert,$I_goback=0) // Function: Illegal operation warning// Parameters: $C_alert (prompted error message) // $I_goback (return to that page) // Return value: word...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template