1. Access to individual characters
In PHP, you can use a string as an array of characters to access the string directly using an array's access method. such as $str[0].
Notice here that if the character is outside of the ASCII code, there is a problem with the access. Because this access can only get one byte.
2. Remove whitespace characters
In PHP, you can use trim (), LTrim (), RTrim () Three functions to remove white space characters at the beginning or end of a string.
where trim () is used to remove whitespace characters before and after a character, LTrim () is used to remove the white space character to the left of the character, and RTrim () is used to remove the white space character to the right of the character.
By default, the following characters are deleted: spaces (| Ox20), Tab tab (\n| Ox09), line wrapping (\n| OXOA), carriage return (\r|0x0d), null character (\0| Ox00).
You can also specify them in the parameters themselves.
3. Change case
Strtolower () converts the entire string to lowercase.
Strtoupper () converts the entire string to uppercase.
Ucfirst () converts the first character of the string to uppercase and the other characters unchanged.
Ucwords () capitalizes the first character of each word in the string, and the other characters are unchanged.
4. HTML Escape
HTML Escape is a string that converts a string into an HTML display. For this, there are two functions in PHP that implement this functionality.
Htmlentities () converts all the characters that can be converted into HTML in addition to the null.
Htmlspecialchars () converts the necessary (with symbol &, double quotes, single quotes, greater than, and less than) to HTML.
5. URL Escape
URL escape refers to converting a string into a URL string. For this, there are two functions in PHP that implement this functionality.
The UrlEncode () and UrlDecode () are converted into a URL string by converting the space into a + number, while the other converts
Rawurlencode () and Rawurldecode () are converted to a% 20th, the normal URL string, the other to the URL string, the former conversion, the latter reverse conversion
6. SQL escape
PHP's most relevant two databases (MySQL and PostgreSQL) are the escape character of the backslash (Oracle is its own definition, the other database is not tested), in this PHP with the addslashes () function to add these backslashes, with stripcslashes () function to remove those backslashes.
Resources:
PHP Programming, 2003, fourth string, accessing a single string; organizing strings; encoding and escaping