1. String connector
The half-width symbol "." is the string connector, which can connect two or more strings into one string. For example:
<?php$name = "PHP中文网:"; $url = echo $name . $url . ".com"; ?>
The running result is: PHP Chinese website: www.php.cn
2. Remove spaces and special characters at the beginning and end of the string
When users enter data, they often enter extra spaces unintentionally. In some cases, In this case, spaces and special characters are not allowed in the string. In this case, the spaces and special characters in the string must be removed.
2.1 trim() function
trim() function is used to remove spaces at the beginning and end of a string, and returns the current string with spaces removed.
Syntax format: string trim(string str [,string charlist]);
The parameter str of the trim() function is the string object to be operated, and the parameter charlist is an optional parameter, specifying that it needs to be deleted from the pending string Specific characters. If this parameter is not set, all optional characters will be deleted. The optional values of parameter charlist are as follows:
Parameter value/description