"PHP" string

Source: Internet
Author: User
Tags string find string splitter

1. How strings are defined:
1. Single quote "'
2. Double quotes ""
3. Delimiter <<< attention at end of use
Example: $str = <<<mystr
String content
mystr; (Shelf written here)

2. Commonly used string output functions:
1.echo: Supports output of one or more variables faster than print
2.print: Usage is similar to echo, but slower than echo

3.die (): Alias exit (), terminates the current script execution, can prompt a statement at the end

4.print_r (): Similar to the Var_dump () function, it is a format variable and is output directly,
Can parse arrays, object types, temporary output (test) for common term development

3. Commonly used string handling functions:
Str_pad () uses a string to populate another string
Str_pad (The string to fill, fill in a few, fill what, and fill it out from there)

*strtolower () The string all lowercase
*strtoupper () capitalizes all strings
*ucfirst () capitalize the first letter of the string
*ucwords () capitalizes the first letter of each word in a string


ASCII: A set of computer coding systems based on the Latin alphabet, mainly used to display modern English and other Western European languages

Ord () returns the ASCII code of the character
Chr () converts ASCII code back to character content

Web page output Format function (escape character):
NL2BR () add \ n before the string () <br/> tag for line break output
*htmlspecialchars () HTML tags in formatted strings
The Strip_tags () function strips HTML, XML, and PHP tags.

Strrev returns the string upside down
*strlen string length Letter: 1 bytes; Kanji: 3 bytes;
*mb_strlen () The length of the text string
*MD5-one-way encrypted, irreversible, because part of the original information in the calculation process is lost.

strcmp () compares the entire string, equal: 0 before > After: + Value after > before:-value
STRNCMP () Specifies the length of the comparison
STRCASECMP () case-insensitive comparison

Similar_text () Fuzzy comparison of two strings $jieguo = (($c/strlen ($a)) *100). " %";

*SUBSTR () string intercept function
*STRSTR () string find and intercept
Alias of the STRCHR () strstr () function
STRRCHR () Looking forward to the specified string

*strpos () to find where a string first appears

Str_replace () string substitution function
Str_replace (strings replaced, strings replaced, original string,);

*ltrim () remove extra characters left (by default, blank)
*rtrim () Remove the right extra character (by default, blank)
**trim () remove extra characters on both sides (by default, whitespace is removed)

**explode () string splitter function
**implode () string combination function

* $_server[' REMOTE_ADDR '] Browse the IP address of the current scripting user
* Date () function to get the current system time
* Time () gets the current system timestamp
* file_get_contents () Get the information in the document
* File_put_contents () write information in the document

"PHP" string

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.