Page 1/3 of php universal detection function set

Source: Internet
Author: User

<?
// [Warning]: do not modify it without permission
// Configure //-----------------------------------------------------------------------------------
-------
// Configure //-----------------------------------------------------------------------------------
-------
//
// [File name]: c_check.inc
// [For use]: universal detection function set
// [Operator]: tianyao
//
// [Last modification date]: 2001/05/11 [cxx]
// [Variable definition rules]: 'C _ '= numeric type,' I _ '= integer type, 'n' _' = numeric type, 'l _ '= boolean type, 'A _ '= Number
Group type
// Configure //-----------------------------------------------------------------------------------
-------
// Configure //-----------------------------------------------------------------------------------
-------
// ※Checkmoney ($ C_Money) checks whether the data is
Format 99999.99
// ※Checkemailaddr ($ C_mailaddr) determines whether the email is a valid email address.
Address
// ※Checkwebaddr ($ C_weburl)
// ※Checkempty ($ C_char) determines whether the string is null.
// ※Checklengthbetween ($ C_char, $ I _len1, $ I _len2 = 100) determines whether it is within the specified length.
String
// ※Checkuser ($ C_user) determines whether the user name is valid.
// ※Checkpassword ($ C_passwd) determines whether the password is valid.
Code
// ※Checktelephone ($ C_telephone) determines whether the phone number is valid.
Code
// ※Checkvaluebetween ($ N_var, $ N_val1, $ N_val2) determines whether it is within a certain range.
Valid Value
// ※Checkpost ($ C_post) determines whether it is a legal zip code (fixed
Fixed Length)
// ※Checkextendname ($ C_filename, $ A_extend) indicates the extension of the uploaded file.
// ※Checkimagesize ($ ImageFileName, $ LimitSize) indicates the size of the uploaded image.
// ※Alertexit ($ C_alert, $ I _goback = 0) indicates an invalid operation and exits.
// ※Alert ($ C_alert, $ I _goback = 0) indicates an invalid operation warning.
// ※Replacespacialchar ($ C_char) Special Character replacement function
// ※Exchangemoney ($ N_money) Fund Conversion Function
// ※Windowlocation ($ C_url, $ C_get = "", $ C_getOther = "") window. location in PHP
Function
// Configure //-----------------------------------------------------------------------------------
-------


// Configure //-----------------------------------------------------------------------------------
-------
// Function name: CheckMoney ($ C_Money)
// For usage: Check whether the data is in the 99999.99 format
// Parameter: $ C_Money (number to be detected)
// Return value: Boolean
// Standby Note: None
// Configure //-----------------------------------------------------------------------------------
-------
Function CheckMoney ($ C_Money)
{
If (! Ereg ("^ [0-9] [.] [0-9] $", $ C_Money) return false;
Return true;
}
// Configure //-----------------------------------------------------------------------------------
-------


// Configure //-----------------------------------------------------------------------------------
-------
// Function name: CheckEmailAddr ($ C_mailaddr)
// Usage: determines whether the email address is a valid email address.
// Parameter: $ C_mailaddr (email address to be detected)
// Return value: Boolean
// Standby Note: None
// Configure //-----------------------------------------------------------------------------------
-------
Function CheckEmailAddr ($ C_mailaddr)
{
If (! Eregi ("^ [_ a-z0-9-] + (. [_ a-z0-9-] +) * @ [a-z0-9-] + (. [a-z0-9-] +) * $ ",
$ C_mailaddr ))
//(! Ereg ("^ [_ a-zA-Z0-9-] + (. [_ a-zA-Z0-9-] +) * @ [_ a-zA-Z0-9-] + (. [_ a-zA-Z0-9-] +) * $ ",
$ C_mailaddr ))
{
Return false;
}
Return true;
}
// Configure //-----------------------------------------------------------------------------------
-------


// Configure //-----------------------------------------------------------------------------------
-------
// Function name: CheckWebAddr ($ C_weburl)
// Usage: Determine whether the website is valid
// Parameter: $ C_weburl (URL to be detected)
// Return value: Boolean
// Standby Note: None
// Configure //-----------------------------------------------------------------------------------
-------
Function CheckWebAddr ($ C_weburl)
{
If (! Ereg ("^ http: // [_ a-zA-Z0-9-] + (. [_ a-zA-Z0-9-] +) * $", $ C_weburl ))
{
Return false;
}
Return true;
}
// Configure //-----------------------------------------------------------------------------------
-------


// Configure //-----------------------------------------------------------------------------------
-------
// Function name: CheckEmpty ($ C_char)
// For usage: determines whether the string is null.
// Parameter: $ C_char (string to be detected)
// Return value: Boolean
// Standby Note: None
// Configure //-----------------------------------------------------------------------------------
-------
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 is set
If ($ C_char = '') return false; // whether it is null
Return true;
}
// Configure //-----------------------------------------------------------------------------------
-------

// Configure //-----------------------------------------------------------------------------------
-------
// Function name: CheckLengthBetween ($ C_char, $ I _len1, $ I _len2 = 100)
// For usage: determines whether the string is within the specified length
// Parameter: $ C_char (string to be detected)
// $ I _len1 (lower limit of the target String Length)
// $ I _len2 (Maximum length of the target string)
// Return value: Boolean
// Standby Note: None
// Configure //-----------------------------------------------------------------------------------
-------
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;
}
// Configure //-----------------------------------------------------------------------------------
-------

// Configure //-----------------------------------------------------------------------------------
-------
// Function name: CheckUser ($ C_user)
// Usage: determines whether the user name is valid
// Parameter: $ C_user (user name to be detected)
// Return value: Boolean
// Standby Note: None
// Configure //-----------------------------------------------------------------------------------
-------
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;
}
// Configure //-----------------------------------------------------------------------------------
-------

// Configure //-----------------------------------------------------------------------------------
-------
// Function name: CheckPassword ($ C_passwd)
// Usage: determines whether the password is valid.
// Parameter: $ C_passwd (password to be detected)
// Return value: Boolean
// Standby Note: None
// Configure //-----------------------------------------------------------------------------------
-------
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;
}
// Configure //-----------------------------------------------------------------------------------
-------

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.