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

PHP general detection function set (2)_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 17:19:52
Original
778 people have browsed it

// Function name: CheckWebAddr($C_weburl)
// Function: Determine whether it is a valid URL
// Parameter: $C_weburl (URL to be detected)
// Return value: Boolean value
// Remarks: None
//------------------------------------------------ ---------------------------------------------
---- ---
function CheckWebAddr($C_weburl)
{
if (!ereg("^http://[_a-zA-Z0-9-]+(.[_a-zA-Z0- 9-]+)*$", $C_weburl))
{
return false;
}
return true;
}
//-------- -------------------------------------------------- --------------------------
-------


//---- -------------------------------------------------- -----------------------------
-------
// Function name: CheckEmpty($ C_char)
// Function: Determine whether the string is empty
// Parameter: $C_char (string to be detected)
// Return value: Boolean value
// Remarks: None
//--------------------------------------------- -------------------------------------
------
function CheckEmptyString($C_char)
{
if (!is_string($C_char)) return false; //Whether it is a string type
if (empty($C_char)) return false; //Whether it has been Set
if ($C_char==) return false; //Whether it is empty
return true;
}
//--------------- -------------------------------------------------- ------------------
-------

//------------- -------------------------------------------------- ------------------
-------
// Function name: CheckLengthBetween($C_char, $I_len1, $I_len2=100)
// Function: Determine whether it is a string within the specified length
// Parameter: $C_char (string to be detected)
// $I_len1 (lower limit of the target string length)
/ / $I_len2 (the upper limit of the target string length)
// Return value: Boolean value
// Remarks: None
//---------------- -------------------------------------------------- ------------------
-------
function CheckLengthBetween($C_cahr, $I_len1, $I_len2=100)
{
$C_cahr = trim($C_cahr);
if (strlen($C_cahr) < $I_len1) return false;
if (strlen($C_cahr) > $I_len2) return false;
return true;
}
//------------------------------------------ -----------------------------------------------
--- ----

//----------------------------------------- ---------------------------------------------
-- -----
// Function name: CheckUser($C_user)
// Function: Determine whether it is a legal user name
// Parameter: $C_user (user name to be detected)
// Return value: Boolean value
// Remarks: None
//-------------------------------- -------------------------------------------------- ---
-------
function CheckUser($C_user)
{
if (!CheckLengthBetween($C_user, 4, 20)) return false; //Width check
if (!ereg("^[_a-zA-Z0-9]*$", $C_user)) return false; //Special character check
return true;
}
//- -------------------------------------------------- --------------------------------
------

// -------------------------------------------------- ----------------------------------
-------
// Function name :CheckPassword($C_passwd)
// Function: Determine whether it is a legal user password
// Parameter: $C_passwd (password to be detected)
// Return value: Boolean value
// Remarks :None
//------------------------------------------------ ----------------------------------------
-------
function CheckPassword($C_passwd)
{
if (!CheckLengthBetween($C_passwd, 4, 20)) return false; //Width detection
if (!ereg("^[_a-zA -Z0-9]*$", $C_passwd)) return false; //Special character detection
return true;
}
//-------------------------- -------------------------------------------------- ------------------
-------

//------------- -------------------------------------------------- --------------------
-------

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532631.htmlTechArticle// Function name: CheckWebAddr($C_weburl) // Function: Determine whether it is a valid URL // Parameter: $ C_weburl (URL to be detected) // Return value: Boolean // Remarks: None //----------...
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template