Course Summary:
This lesson enables you to perform basic operations on strings.
String Knowledge Points:
1. Introduction to String processing
2. Commonly used string output functions
3. Commonly used string formatting functions
4. String comparison function
5. The application of regular expressions in strings
6. Regular expressions used with Per1
1.pathinfo ();//return path information for the domain name
2.parse_url ();
3.PARSE_STR ()//used to split parameters
PathInfo ();
";
Print_r ($arr);
echo "
";?>
Split a domain name into an array
";
Print_r ($arr 4);
echo "
";?>
The same method takes
";
Print_r ($arr 4);
echo "
";?>
Method 3
";
Print_r ($arr 3);
echo "
";?>
String Knowledge Points:
1. Introduction to String processing
2. Commonly used string output functions
3. Commonly used string formatting functions
4. String comparison function
5. The application of regular expressions in strings
6. Regular expressions used with Per1
String functions
Echo
Print
printf (); Direct output
sprintf () Direct return
Connector for string:
. Connect with Dots
print "AAAAAAAAAA";
printf ("----%s--$s-", $a, $b);
%s string
%d digits
%f floating-point type (%.2f indicates two digits after the decimal point)
sprintf (); does not output directly, returns a new variable
Common string Formatting functions:
1. Remove space and string fill function
1.ltrim (); Remove left space
2.rtrim (); Remove Right space
3.trim (); Remove both sides of the space
4.str_pad ()//To fill a space or a custom character to a specified length
5.str_repeat ()//used to repeat the preceding character (for making an infinite category menu)
6.strlen ()//Get string length
echo "". Str_repeat ("-", 5). " BB ";
String Case Conversion function
1.strtoupper ();//all converted to uppercase
2.strtolower ();//convert All to lowercase
3.ucfirst ();//First Capital letter
4.ucwords (); Capitalize the first letter of each letter
Other string formatting functions:
1.strlen ();//String length
2.strrev ();//Flip string
3.number_format ();//format words numeric character function
4.MD5//MD5 Encrypted string, 32-bit string
5.str_shuffle (), randomly scrambling strings, the number of digits is not changed
String functions:
String functions associated with HTML:
1.NL2BR (): Convert/N to BR label
2.htmlspecialchars (); Turn entity
' "< > & Convert to Entity
": Represents an entity
The less-than number
: Greater than number
3.addslashes ()//' "" \ Front plus \ Reduce damage to the database
4.stripslashes ()//' "" \ front/Remove
3.strip_tags (); Just keep some labels and remove the labels you want to remove
Note: It is recommended that three controls be made before the database is inserted into the database
1. Only limited label, do label filter
2.addslashes ();
' "" \ Front plus \ Reduce damage to the database
3.htmlspecialchars ()
' "< > & Convert to Entity to prevent the database from being photographed pretty fast