1. String output function
echo
is not as efficient as echo and is not recommended to use
die()
Exit and print string a, too You can directly die
printf
formatted string
sprintf
return the formatted string
2. Commonly used string formatting functions
ltrim ()
Remove the white space on the left side
rtrim
Remove the white space on the right side
trim
Remove the white space on both sides
str_pad
Padding a string with another string to the specified length
strtolower
Convert a string to lowercase
strtopper
Convert a string to uppercase
ucfirst
Convert the first letter of the string to uppercase
usword
Convert the first letter of each word in the string to uppercase
nl2br
Insert HTML newline mark before all new lines in the string
htmlentities
Entities converted to tags
htmlspecialchars
Convert tags to entities
...
3. String comparison function
strcmp(a,b)
is sorted by bytes. If a is less than
b, a negative number is returned; if
is greater than b, a positive number is returned; if they are equal, 0 is returned.
strcasecmp()
Same as above, but not case sensitive
strnatcmp()
Sort by natural numbers
The above has introduced the string processing function, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.