PHP character function Encyclopedia

Source: Internet
Author: User
Tags chop chr crypt md5 ord sprintf strlen trim

Addslashes: String add Slash.

Bin2Hex: The binary turns into 16 carry.

Chop: Remove continuous blank.

CHR: Returns the character of the ordinal value.

Chunk_split: Splits the string into small segments.

Convert_cyr_string: Converts the ancient Slavic string into other strings.

Crypt: Encrypts the string with DES encoding.

Echo: Output string.

Explode: Cut the string.

Flush: Clear out the output buffer.

Get_meta_tags: Extracts all meta tags from documents.

Htmlspecialchars: Converts special characters into HTML format.

Htmlentities: Converts all characters into an HTML string.

Implode: Converts an array into a string.

Join: Converts an array into a string.

LTrim: Remove continuous blank.

MD5: Computes the string of MD5.

NL2BR: Convert newline characters to <br>.

ORD: Returns the ordinal value of a character.

PARSE_STR: Parse query string into variables.

Print: Output string.

printf: Output format string.

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

Quotemeta: Add reference symbol.

Rawurldecode: Revert from URL private format string to normal string.

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

SetLocale: Configure geographic information.

Similar_text: Computes string similarity.

Soundex: Calculating the pronunciation value of a string

sprintf: Format the string.

STRCHR: Find the first character that appears.

strcmp: string comparison.

STRCSPN: Length of different strings.

Strip_tags: Get rid of HTML and PHP tags.

Stripslashes: Remove backslash characters.

Strlen: Gets the string length.

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

Strpos: Looks for a character in the string to appear first.

STRRCHR: Gets the string at which a character last appears.

Strrev: Reverses the string.

STRSPN: Find out the number of strings that fall into another string mask.

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

Strtok: Cut the string.

Strtolower: The string is all converted to lowercase.

Strtoupper: The string is all capitalized.

Str_replace: String substitution.

STRTR: Converts certain characters.

SUBSTR: Take a partial string.

Trim: Truncate the trailing space of the string.

Ucfirst: Capitalize the first character of the string.

Ucwords: Capitalize the first letter of each word in the string.

return value: String

Function type: Data processing

Description: This function makes it possible for database queries (query) to run smoothly by using the string, quotation marks, and quotes that need to be processed by the database. The characters that will be changed include single quotes ('), double quotes ("), backslash backslash (), and null character NUL (the null byte).

Reference: Stripslashes () Htmlspecialchars () Quotemeta ()

return value: String

Function type: Data processing

Description: This function enables the binary string to be turned into a 16-digit 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 continuous white space 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 ("End character of string:%c", 27);

?>

Reference: Ord () sprintf ()

return value: String

Function type: Data processing

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

  Usage examples

Format a string $data into a MIME BASE64 format

?

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

?>

Reference: Ereg_replace ()

return value: String

Function type: Data processing

  Description: This function turns the Cyrillic string into another string. The From and to two parameters are characters and 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 standard UNIX encryption 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's parameters, and then compare the encrypted string.

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

In some newer versions of UNIX, other encryption modules, such as MD5, are available in addition to DES. Even some systems use MD5 instead of DES. There are some changes in the salt parameters, which are determined by the length of the string passed to the Salt parameter:

Crypt_std_des-Standard DES encoding, enter 2-character salt.

Crypt_ext_des-Extended DES encoding, enter 9-character salt.

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 real function, there is no return value.

  Usage examples

<?php

echo "Hello World";

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.