Php string type description, php string description. Php string type description. php string description PHP supports eight primitive types ). Four scalar types: two compound types: two special types: string type, one character, php string type, and php string
PHP supports eight primitive types ).
Four scalar types:
Two composite types:
Two special types:
String type
A string is a string of characters, like "Hello world! ".
There are three methods to define a string:
1. single quotes
Enclose a string with single quotes (') is the easiest way to define a string:
If the string contains single quotation marks, escape using the backslash:
Tip: If a backslash is required before single quotes or at the end of a string, two backslashes are required. In other words, the backslash only escapes the 'character here, but does not escape other characters.
If you only define a simple string without parsing more content, it is obviously more efficient to use single quotes.
2. double quotation marks
If you use double quotation marks (") to define strings, PHP understands the escape sequence of more special characters:
Escape sequence |
Description |
\ N |
Line Feed |
\ R |
Enter |
\ T |
Horizontal Tab |
\ [/Td> |
Backslash |
\ $ |
Dollar Sign |
\" |
Double quotation marks |
\ [0-7] {1, 3} |
This regular expression matches a character in the octal symbol. |
\ X [0-9A-Fa-f] {1, 2} |
This regular expression matches a character in the hexadecimal notation. |
Example:
Note that the line feed in this example refers to the line feed in the text sense. to display the line feed in the browser, use the nl2br () function to replace \ n
.
The most important aspect of a double quotation mark string is that the variable name is replaced by the variable value parsing:
3. definition of delimiters
The delimiter definition string uses the delimiter syntax (<), provides an identifier after the delimiter, then the defined string, and ends the string definition with the same identifier.
Example:
In this example, EOD is the identifier. The end identifier must start from the first column of the row. Similarly, the identifier must follow the naming rules for any other tag in PHP: it can only contain letters, numbers, underscores (_), and must start with an underscore or a non-digit character.
Note:The row where the end identifier is located cannot contain any other characters (except a semicolon;), including line indentation.
Tip:A string is not only a number of characters shown in the preceding example, but can also be defined as a string or even a huge long text, which is different from the char definition in the database.
Address: http://www.manongjc.com/php/php_string.html
Related reading:
Php uses the str_word_count () function to calculate the number of words in a string.
Php str_split () splits the string into N parts and saves them to the array.
Php str_shuffle breaks the string and randomly arranges the characters of the string
The php str_rot13 () function obtains the ROT13 encoding of the string.
Php str_repeat () repeats the string N times
PHP supports eight primitive types ). Four scalar types: two compound types: two special types: string type, one character...