The string control function in PHP is more effective, and the following are important: (1) the first two functions of echo, print, printf, and sprintf are output strings. if there is a variable name in the string, it is converted to its value. the last two functions are similar to C functions with the same name. (2) strchr,
The string control function in PHP is more effective, and the following are important:
(1) echo, print, printf, sprintf
The first two functions are output strings. if there is a variable name in the string, it is converted to its value.
The last two functions are similar to C functions with the same name.
(2) strchr, strlen, strtok, strrchr, strrev, strstr, strtolower,
Strtoupper, substr, ucfirst
These are commonly used string control functions, and some of them have the same meaning as the functions of the same name in C.
Strrev is used to flip a string.
The meaning of strtolower and strtoupper should be clear.
Ucfirst converts the first character of a string to uppercase.
Substr is a substring of the returned string. its usage is substr (string, header, length ).
The header position is counted from 0. if it is a negative number, it indicates a forward number from the tail.
(3) Chr, Ord
Similar to C functions with the same name.
(4) explode, implode, join
These are functions related to arrays.
Explode (string, delimiter) returns an array generated when the string is removed from the delimiter.
Implode (array, delimiter) returns a string that inserts a delimiter into each element of the array.
Join and implode have the same meaning.
(5) Chop
Removes the vacancy at the end of the string.
(6) htmlspecialchars
Replace the special HTML characters in the string with their names, for example, \ '<\' into \ '<\'.
(7) nl2br
Add \ 'before each carriage return in the string \'
\'.
(8) AddSlashes, StripSlashes
The \ 'character must be added to the string for database query and \' is dropped \'\\'.
(9) parse_str
Analyze a string of the \ 'name1 = value1 & name2 = value2 &... \ 'type into some variables.
For example:
Parse_str (\ 'a = 1 & B = 2 \');
Two variables, $ a and $ B, are generated. the values are divided into 1, 2.
If there are two pairs of names/values with the same name, then the value of the last is shrouded in the previous one.
If the two pairs have \ '[] \' at the end, for example, \ 'a [] = 1 & a [] = 2 \ ', then the native array $, the two elements are distinguished as 1, 2.