PHP character functions Daquan _php tutorial

Source: Internet
Author: User
Tags chop crypt
Addslashes: String joins a slash.

Bin2Hex: binary turns into 16 decimal.

Chop: Remove continuous whitespace.

CHR: The character that returns the ordinal value.

Chunk_split: Divides the string into small segments.

Convert_cyr_string: Converts an old Slavic string into another string.

Crypt: The string is encrypted with DES encoding.

Echo: the output string.

Explode: Cuts the string.

Flush: Clear out the output buffer.

Get_meta_tags: Extract data from all meta tags of the file.

Htmlspecialchars: Converts special characters into HTML format.

Htmlentities: Turns all characters into HTML strings.

Implode: Turns the array into a string.

Join: Turns the array into a string.

LTrim: Remove continuous whitespace.

MD5: Computes the MD5 of the string.

NL2BR: Converts a newline character to

ORD: Returns the ordinal value of a character.

PARSE_STR: Parses the query string into a variable.

Print: Output string.

printf: Output formatted string.

Quoted_printable_decode: Converts a QP encoded string into a 8-bit string.

Quotemeta: Add reference symbol.

Rawurldecode: Restore from a URL-specific format string to a normal string.

Rawurlencode: Encodes a string into a URL-specific format.

SetLocale: Configure geo-information.

Similar_text: Calculates the similarity of strings.

Soundex: Calculating the phonetic value of a string

sprintf: Formats the string.

STRCHR: Look for the first occurrence of the character.

strcmp: string comparison.

STRCSPN: The length of different strings.

Strip_tags: Remove HTML and PHP markup.

Stripslashes: Remove the backslash character.

Strlen: Gets the string length.

Strrpos: Looks for a character in the string where the last occurrence occurs.

Strpos: Looks for a character in a string that appears first.

STRRCHR: Gets the string that appears at the last occurrence of a character.

Strrev: Reverses the string.

STRSPN: Find out how many strings fall in another string mask.

Strstr: Returns the string from the beginning of the string to the end of a string.

Strtok: Cuts the string.

Strtolower: All strings are converted to lowercase.

Strtoupper: All strings are capitalized.

Str_replace: String substitution.

STRTR: Converts some characters.

SUBSTR: Takes a partial string.

Trim: Truncate the space between the end of the string.

Ucfirst: capitalizes the first character of the string.

Ucwords: capitalizes the first letter of each word in a string.

return value: String

Function type: Data processing

Description: This function makes it necessary for the database to process the string, quotation marks, and a diagonal line for the database queries (query) to work smoothly. The characters that will be changed include single quotation marks ('), double quotation marks ("), backslash backslash (), and null character NUL (the null byte).

Reference: Stripslashes () Htmlspecialchars () Quotemeta ()

return value: String

Function type: Data processing

Description: This function allows the binary string to be converted to a 16-character string.

  Usage examples

Add:

  a function that converts 16 to binary .

  

function Hex2bin ($data) {

$len = strlen ($data);

for ($i =0; $i < $len; $i +=2) {

$newdata. = Pack ("C", Hexdec (substr ($string, $i, 2)));

}

return $newdata;

}

?>

return value: String

Function type: Data processing

Description: This function clears the contiguous whitespace of the string.

Usage examples

  

$trimmed = Chop ($line);

?>

Reference: Trim ()

return value: String

Function type: Data processing

Description: This function converts the ordinal of a character to an ASCII character. This function is compared with Ord ().

Usage examples

  

$str. = Chr (27);

$str = sprintf ("The end character of the string is:%c", 27);

?>

Reference: Ord () sprintf ()

return value: String

Function type: Data processing

  Description: This function turns the character into a small segment for use by other functions. For example, Base64_encode. The default is the parameter Chunklen (76 characters) to insert end ("RN") every 76 characters. Returns a new string without altering the original string.

  Usage examples

Format a string $data as a MIME BASE64 format

  

$new _string = Chunk_split (Base64_encode ($data));

?>

Reference: Ereg_replace ()

return value: String

Function type: Data processing

  Description: This function converts an old Slavic string into another string. The From and to two parameters are characters, which represent the following meanings:

K-koi8-r

w-windows-1251

I-iso8859-5

a-x-cp866

d-x-cp866

M-x-mac-cyrillic

Syntax: String crypt (String str, string [salt]);

return value: String

Function type: Encoding processing

  Description: This function encrypts the string with the UNIX standard cryptographic DES module. This is a one-way cryptographic function that cannot be decrypted. To compare strings, place the first two characters of the encrypted string in the salt parameter, and then the encrypted string.

For more detailed information, refer to crypt in UNIX Manual (man).

In some newer versions of UNIX, other cryptographic modules, such as MD5, are available in addition to DES. Even some systems replace DES with MD5. There are some changes in the salt parameter, which depends on the length of the string passed to the Salt parameter:

Crypt_std_des-Standard DES encoding, enter a salt of 2 characters.

Crypt_ext_des-Extended DES encoding, enter a salt of 9 characters.

CRYPT_MD5-MD5 code, enter 12 characters plus $1$ salt.

Crypt_blowfish-Extended DES encoding, enter 16 characters plus $2$ salt.

In addition, if you do not use the salt parameter, the program is automatically generated.

return value: None

Function type: PHP system function

  Description: This function outputs a string. Because it is not a true function, there is no return value.

  Usage examples

  

echo "Hello World";

http://www.bkjia.com/PHPjc/371753.html www.bkjia.com true http://www.bkjia.com/PHPjc/371753.html techarticle addslashes: String joins a slash. Bin2Hex: binary turns into 16 decimal. Chop: Remove continuous whitespace. CHR: The character that returns the ordinal value. Chunk_split: Divides the string into small segments. C ...

  • 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.