First, the formatting of the string
1. Processing of strings: trim (), LTrim (), RTrim ()
$name =trim ($_post[' name "), $name =trim ($_post[' password ')), $name =trim ($_post[' email ');
The trim () function can strip the starting and ending spaces of a string and return the resulting string, by default the characters that are stripped are line feed and carriage return (\ n and \ r), Horizontal and Vertical tabs (\ T and x0b)
The LTrim () function removes spaces only from the beginning of the character (left)
The RTrim () function removes spaces only from the end of the function (right)
2. Format the string to display
① Using HTML formatting: n12br () function
Insert a newline character before a new line (\ n) in a string
ResultsOne line. Another line.
② formatting a string for print output
printf () structure
$s = "world");p rintf ("Hello%s", $s);
3. Change the case of letters in a string
Function |
Describe |
Using $subject =hello World |
return value |
Strtoupper () |
Convert a string to uppercase |
Strtoupper ($subject) |
HELLO World |
Strtolower () |
Convert a string to lowercase |
Strtolower ($subject) |
Hello World |
Ucfirst () |
If the first character of a string is a character, capitalize it |
Ucfirst ($subject) |
Hello World |
Ucwords () |
Capitalize the first letter of each word of a string |
Ucwords ($subject) |
Hello World |
---------------------------------------------------------
Not finished
The above describes the PHP diary (a) string operations, including PHP, string aspects of the content, I hope to be interested in PHP tutorial friends helpful.