PHP character functions Daquan _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
Tags chop crypt
PHP character functions. AddSlashes: Adds a slash to the string. Bin2hex: binary to hexadecimal. Chop: removes consecutive gaps. Chr: returns the character of the ordinal value. Chunk_split: splits a string into segments. C AddSlashes: Adds a slash to the string.

Bin2hex: binary to hexadecimal.

Chop: removes consecutive gaps.

Chr: returns the character of the ordinal value.

Chunk_split: splits a string into segments.

Convert_cyr_string: convert the ancient Slavic string to another string.

Crypt: encrypt the string with DES encoding.

Echo: output string.

Explode: cut string.

Flush: clears the output buffer.

Get_meta_tags: extracts all metadata marked by meta from the file.

Htmlspecialchars: Convert Special characters into HTML format.

Htmlentities: converts all characters into HTML strings.

Implode: converts an array into a string.

Join: converts an array into a string.

Ltrim: removes consecutive white spaces.

Md5: calculate the MD5 of the string.

Nl2br: convert line breaks
.

Ord: returns the ordinal value of a character.

Parse_str: parses the query string into a variable.

Print: output string.

Printf: output the formatted string.

Quoted_printable_decode: convert an qp encoded string to an 8-bit string.

QuoteMeta: add a reference symbol.

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

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

Setlocale: configure the region information.

Similar_text: string similarity calculation.

Soundex: calculates the pronunciation of a string.

Sprintf: format the string.

Strchr: find the first occurrence character.

Strcmp: string comparison.

Strcspns: the length of different strings.

Strip_tags: removes HTML and PHP tags.

StripSlashes: removes the backslash.

Strlen: Gets the string length.

Strrpos: find the last occurrence of a character in the string.

Strpos: searches for the first occurrence of a character in a string.

Strrchr: Gets the string starting from the last occurrence of a character.

Strrev: Reverse string.

Strspns: identifies the number of masks that a string falls into another string.

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

Strtok: cut string.

Strtolower: converts all strings to lowercase letters.

Strtoupper: converts all strings to uppercase.

Str_replace: string replacement.

Strtr: converts certain characters.

Substr: obtains some strings.

Trim: removes spaces at the beginning and end of a string.

Ucfirst: uppercase for the first character of the string.

Ucwords: change the first letter of each character in the string to uppercase.

Return value: string

Function type: data processing

Description: This function allows the database to process strings with diagonal lines added to the quotation marks for the database query to operate smoothly. The modified characters include single quotation marks ('), double quotation marks ("), backslash (), and null characters NUL (the null byte ).

Reference: stripslashes () htmlspecialchars () quotemeta ()

Return value: string

Function type: data processing

Description: This function converts a binary string to a hexadecimal string.

  Example

Supplement:

  A function that converts hexadecimal 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 consecutive blank spaces of strings.

Example

  

$ Trimmed = Chop ($ line );

?>

Reference: trim ()

Return value: string

Function type: data processing

Description: This function converts the ordinal number of characters into ASCII characters. This function is compared with ord.

Example

  

$ 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 converts characters into small segments for other functions. For example, base64_encode. It is determined that the chunklen parameter (76 characters) is inserted with end ("rn") every 76 characters "). Returns a new string without modifying the original string.

  Example

Format string $ data into MIME BASE64 format

  

$ New_string = chunk_split (base64_encode ($ data ));

?>

Reference: ereg_replace ()

Return value: string

Function type: data processing

  Description:This function converts the string of the ancient Slavic to another string. THE from and to parameters are characters and their meanings are as follows:

K-koi8-r

Ws-windows-1251

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

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

For more information, see crypt in UNIX Manual (man.

In some newer UNIX versions, apart from DES, other encryption modules, such as MD5, are provided. Even some systems use MD5 instead of DES. There are still some changes to the salt parameter, depending on the length of the string passed to the salt parameter:

CRYPT_STD_DES-Standard DES encoding, which is a 2-character salt.

CRYPT_EXT_DES-extended DES encoding, which is a 9-character salt.

CRYPT_MD5-MD5 encoding, input 12 characters plus $1 $ salt.

CRYPT_BLOWFISH-extended DES encoding. input 16 characters plus $2 $ salt.

In addition, if the salt parameter is not used, the program will automatically generate it.

Return value: None

Function types: PHP system functions

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

  Example

  

Echo "Hello World ";

The delimiter string is added with a diagonal line. Bin2hex: binary to hexadecimal. Chop: removes consecutive gaps. Chr: returns the character of the ordinal value. Chunk_split: splits a string into segments. C...

Large-Scale Price Reduction
  • 59% Max. and 23% Avg.
  • Price Reduction for Core Products
  • Price Reduction in Multiple Regions
undefined. /
Connect with us on Discord
  • Secure, anonymous group chat without disturbance
  • Stay updated on campaigns, new products, and more
  • Support for all your questions
undefined. /
Free Tier
  • Start free from ECS to Big Data
  • Get Started in 3 Simple Steps
  • Try ECS t5 1C1G
undefined. /

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.