PHP character function Daquan 1th/2 page _php Basics

Source: Internet
Author: User
Tags chop chr explode flush imap ord sprintf string format
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:
Josh@superfork.com (22-jun-1999) writes 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 ("\ r \ n") 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";
?>
Reference: Print () printf () flush ()


return value: Array
Function type: Data processing
Description: This function separator The string according to the specified string or character. Returns the cut string to the array variable.
Usage examples
?
$pizza = "The first piece of the second piece of the third piece of the sixth film";
$pieces = Explode ("", $pizza);
?>
Reference: Implode ()


return value: None
Function type: Data processing
Content Description: This function has no input and no output. Send out the data of the output buffer and clear it out.


Syntax: Array get_meta_tags (string filename, int [use_include_path]);
return value: Array
Function type: Data processing
Description: This function takes all the <meta ......> tags in the homepage and places the array variables back. For example
<meta content= "Pengwuchen" >
<meta content= "PHP BIBLE" >
<title>php bible</title>
This function finds the META tag, the string for the name attribute is an array index, and the Content property string is the data for the array.  pay attention to this function is the PHP native function, on the UNIX series platform can not directly deal with the Macintosh file format, because the newline characters are different. Blake@mediaone.net points out (07-jun-1999) that the parameter filename can also be a URL, and the function pulls out the file meta tag of the remote server. When a function is processed, it encounters the end of the

Syntax: String htmlspecialchars (String string);
return value: String
Function type: Data processing
Description: This function converts special characters into an HTML string format (&....;). The most commonly used occasions may be to deal with the message version of the customer message.
& (and) Convert to &
"(double quotes) into"
< (less than) turn into <
> (greater than) convert to >
This function converts only the special characters above, and does not convert all to the ASCII conversion specified by HTML.
Usage examples
This is the example provided by Aulbach@unter.franken.de (27-jan-1999)
<form action=bla>
Name of Restaurant:
<input type=text value= ".
echo Htmlspecialchars ($restname);?> ">
<!--variable $restname is the $restname of sauces = "" "The White Horse\" "; -->
<BR>
Input description (if you will HTML, can be used directly): <BR>
<textarea ><?
echo Htmlspecialchars ($descript);
?></textarea>
<input type=submit>
</FORM>
Reference: Htmlentities () nl2br ()


Syntax: String htmlentities (String string);
return value: String
Function type: Data processing
Description: This function is a bit like the Htmlspecialchars () function, but this function converts all string characters to an HTML special character set string. However, after the conversion of reading the source code of the Web page, there will be a lot of trouble, especially the source code in the text will become unintelligible, the browser is still normal to see.


return value: String
Function type: Data processing
Description: This function combines the contents of an array into a string, and the parameter glue is a delimiter between words.
Usage examples
?
$colon _separated = Implode (":", $array);
echo $colon _separated;
?>
Reference: Explode () join () split ()


return value: String
Function type: Data processing
Description: This function is an alias for the implode function.


return value: String
Function type: Data processing
Description: This function is used to delete the continuous blank (whitespace) in the string.


Syntax: string MD5 (string str);
return value: String
Function type: Encoding processing
Content Description: This function is used to calculate MD5. For MD5 encoding, you can refer to RSA Data Security, Inc. MD5 message-digest algorithm. RFC1321, or Raixi pine, Freshfields, Zhang sincerity and so on with the modern cryptography and its application, 11.3.


Syntax: String nl2br (String string);
return value: String
Function type: Data processing
Description: This function converts line-wrapping characters into HTML line-wrapping <br> instructions.
Reference: Htmlspecialchars () htmlentities ()


return value: Integer
Function type: Data processing
Description: This function returns the ASCII (US National Standard Exchange code) ordinal value of the character. This function is the opposite of the Chr () function.
Usage examples
<?php
if (ord ($str) = = 10) {
The first word of echo ("string \ $str" is a newline character. \ n ");
}
?>
Reference: Chr ()


Syntax: void Parse_str (String str);
return value: None
Function type: Data processing
Content Description: This function can parse the query_string string of the Get method returned by the browser. The variable name and value returned depend on the name and value of the query_string.
Usage examples
<?php
$str = "First=value&second[]=this+works&second[]=another";
Parse_str ($STR);
Echo $first; Display the "value" string
echo $second [0]; Display the "This Works" string
echo $second [1]; Display the "another" string
?>


Return Value: Boolean value
Function type: Data processing
Content Description: This function output string. If successful, return 1, failure returns 0. For example, when the client's browser suddenly hangs, it will cause the output to fail.
Reference: Echo () printf () flush ()


return value: Integer
Function type: Data processing
Description: This function formats the string according to the content format specified by the parameter format. Details of the format can be referred to sprintf ().
Reference: Print () sprintf () flush ()


Syntax: string quoted_printable_decode (String str);
return value: String
Function type: Encoding processing
Description: This function can decode the quoted-printable string into a 8-bit encoded string. And this function is similar to the Imap_qprint () function, only a different place is to use the Imap_qprint () function requires the system to join the IMAP module, and this function does not need an IMAP module.


return value: String
Function type: Data processing
Content Description: This function will contain the string. \\ + * ? [ ^ ] ($) Precede the character with the backslash "\" symbol.
Reference: Addslashes () htmlentities () Htmlspecialchars () nl2br () stripslashes ()


Syntax: string rawurldecode (String str);
return value: String
Function type: Encoding processing
Content Description: This function decodes a string. From a string-specific format of the URL to a normal string. Detailed coding and decoding information and specifications can be referenced in RFC 1738.
Reference: Rawurlencode ()


Syntax: string rawurldecode (String str);
return value: String
Function type: Encoding processing
Description: This function encodes a string into a string-specific format for a URL, and special characters are converted to a percent symbol followed by a two 16-digit format. For example, the space will become% 20.
Usage examples
<?php
Echo ' <a href= ' ftp://guest: ', Rawurlencode (' foo @+%/'), ' @localhost/x.txt ' >;
?>
Reference: Rawurldecode ()
Current 1/2 page 12 Next read the full text

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.