We are learningPHP string operations (1) echo, print, printf, sprintf
The first two functions are output strings. If there is a variable name in the string, it is replaced with its value.
The last two functions are similar to C functions with the same name.
PHP string operations (2) strchr, strlen, strtok, strrchr, strrev, strstr, strtolower,
Strtoupper, substr, ucfirst
These are common PHP string operations, and some functions with the same name in C have exactly the same meaning.
Strrev is used to flip a string.
The meaning of strtolower and strtoupper should not be explained.
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 the forward number from the tail.
PHP string operations (3) Chr, Ord
Similar to C functions with the same name.
PHP string Operations (4) explode, implode, join
These are functions related to arrays.
Explode (string, delimiter) returns an array generated when the string is split.
Implode (array, delimiter) returns a string that inserts a delimiter into each element of the array.
Join and implode have the same meaning.
PHP string operation (5) Chop
Removes the white space at the end of the string.
PHP string operations (6) htmlspecialchars
Replace the special HTML characters in the string with their names, for example, "<" to "<".
PHP string operation (7) nl2br
Add "<BR>" before each carriage return in the string ".
PHP string operations (8) AddSlashes, StripSlashes
Add "" to the string to be used for database query and remove "".
PHP string operation (9) parse_str
Analyze the string of the "name1 = value1 & name2 = value2 &..." type into some variables.
For example:
Parse_str ("a = 1 & B = 2 ");
Generate two variables, $ a and $ B. The values are 1, 2, respectively.
If two pairs of Names/values have the same name, the latter value overwrites the previous one.
If the two pairs have "[]" at the end, for example, "a [] = 1 & a [] = 2", an array $ a is generated, and the two elements are 1, 2, and 2 respectively.