1. String processing: trim(), ltrim(), rtrim()
$name=trim($_POST['name']); $name=trim($_POST['password']); $name=trim($_POST['email']);
trim() function can remove the spaces at the beginning and end of the string, And return the result string. By default, the characters removed are line feed and carriage return characters (n and r), horizontal and vertical tab characters (t and X0B). The ltrim() function only starts from the beginning of the character ( Left) Remove spaces
rtrim() function only removes spaces from the end of the function (right)
2. Format the string for display
①Use HTML formatting: n12br() function
in Insert newline character before newline(n) in string <span style="white-space:pre"> </span><pre name="code" class="html"><?php
echo nl2br("One line.\nAnother line.");
?>
One line. Another line.
printf() structure
$s="world"); printf("Hello %s",$s);
Description | Use $subject=Hello World | Return value | |
Convert the string to uppercase | strtoupper($subject) | HELLO WORLD | |
Convert the string to lowercase | strtolower($sub ject ) | hello world | |
If the first character of the string is a character, convert it to uppercase | ucfirst($subject) | Hello world | |
will Capitalize the first letter of each word in the string | ucwords($subject) | Hello World |
Not finished