PHP string functions and usage analysis

Source: Internet
Author: User
Keywords Network programming PHP tutorial
Tags .mall added analysis binary clear continuous convert_cyr_string data

AddSlashes: String added to the slash.
bin2hex: binary into hexadecimal.
Chop: Remove continuous blanks.
Chr: returns the ordinal value of the character.
chunk_split: The string is divided into small pieces.
convert_cyr_string: Converts the ancient Slavonic string into another string.
crypt: Encrypt the string with DES encoding.
echo: output string.
explode: cut the string.
flush: clear the output buffer.
get_meta_tags: extract all meta tags of the file information.
htmlspecialchars: special characters into HTML format.
htmlentities: all characters are converted to HTML string.
implode: the array into a string.
join: the array into a string.
ltrim: remove continuous blank.
md5: Calculate string MD5 hale.
nl2br: convert linefeed characters to <br>.
Ord: returns the ordinal value of the character.
parse_str: Parse the query string into variables.
print: output string.
printf: Output formatted string.
quoted_printable_decode: Convert qp encoded strings to 8-bit strings.
QuoteMeta: Add reference symbol.
rawurldecode: Restore from a URL-specific format string to a normal string.
rawurlencode: encodes the string into a URL-specific format.
setlocale: configure the localization information.
similar_text: Calculate String Similarity.
soundex: Calculates the pronunciation of a string
sprintf: format string.
strchr: Find the first occurrence of the character.
strcmp: string comparison.
strcspn: different string length.
strip_tags: Remove HTML and PHP tags.
StripSlashes: Remove the backslash character.
strlen: Get the string length.
strrpos: find the last character of a string where Department.
strpos: find the first occurrence of a character string.
strrchr: get the last occurrence of a character string.
strrev: inverted string.
strspn: Find out the number of strings that one string falls in another.
strstr: returns a string from the beginning to the end of a string.
strtok: cut the string.
strtolower: string all lowercase.
strtoupper: string all the capitalization.
str_replace: String replaced.
strtr: convert some characters.
substr: take part of the string.
trim: truncated string of spaces.
ucfirst: the first character of the string to capitalize.
ucwords: the first letter of each character string to capitalize.

addslashes
Return value: String Function type: Data processing Description: This function makes the database need to deal with the string, the part of the quotation marks plus slash, for the database query (query) can operate smoothly. These characters that can be changed include single quotes (''), double quotes ("), backslash (), and the null character NUL (null).
Reference: stripslashes () htmlspecialchars () quotemeta ()

bin2hex
Return Value: String Function Type: Data Processing Description: This function converts a binary string into a hexadecimal string.
Use example to add:
josh@superfork.com (22-Jun-1999) wrote a function that converts hexadecimal bits 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;
}
?>

chop
Return Value: String Function Type: Data Processing Description: This function will clear the continuous blank of the string.
Use example
<?
$ trimmed = Chop ($ line);
?>
Reference: trim ()

chr
Return Value: String Function Type: Data Processing Description: This function converts the ordinal number of characters into ASCII characters. This function is collated with ord ().

Related Article

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.