1. The difference between UrlEncode and Rawurlencode
<?php Test (' https://tieba.baidu.com/f?kw=2&fr=wwwt '), Test (':/?= '), Test (' test '), function test ($s) {echo "<b>urlencode (' $s ') </b> = [<b>"; Var_dump (UrlEncode ($s)); echo "</b>]<br/>"; echo "<b>rawurlencode (' $s ') </b> = [<b>"; Var_dump (Rawurlencode ($s)); echo "</b>]<br/>";} Run result UrlEncode (' https://tieba.baidu.com/f?kw=2&fr=wwwt ') = [D:\software\wamp\www\linux\webapi\test.php:9: String ' HTTPS%3A%2F%2FTIEBA.BAIDU.COM%2FF%3FKW%3D2%26FR%3DWWWT ' (length=54)]rawurlencode (' https:// TIEBA.BAIDU.COM/F?KW=2&FR=WWWT ') = [d:\software\wamp\www\linux\webapi\test.php:12:string ' https%3A%2F% 2FTIEBA.BAIDU.COM%2FF%3FKW%3D2%26FR%3DWWWT ' (length=54)]urlencode (':/?= ') = [D:\software\wamp\www\linux\ Webapi\test.php:9:string '%3a%2f%3f%3d+%26%23 ' (length=19)]rawurlencode (':/?= ') = [D:\software\wamp\www\ Linux\webapi\test.php:12:string '%3a%2f%3f%3d%20%26%23 ' (length=21)]urlencode (' test ') = [D:\SOFTWARE\WAMP\WWW\linux\webapi\test.php:9:string '%e6%b5%8b%e8%af%95 ' (length=18)]rawurlencode (' test ') = [D:\software\wamp\www\linux \webapi\test.php:12:string '%e6%b5%8b%e8%af%95 ' (length=18)]
From the above implementation results can be seen, UrlEncode and Rawurlencode two methods in the processing of alphanumeric, special symbols, Chinese when the results are the same, the only difference is the processing of the space, UrlEncode processing into "+", Rawurlencode processing into " %20
2. Function Strip_tags: Remove HTML and PHP tags
Note: This function removes any HTML and PHP tag strings that are contained in the string. If the string of HTML and PHP tags are wrong, for example, less than the symbol, it will also return errors. This function and FGETSS () have the same function. FGETSS is to read the file from the file and remove the HTML and PHP tags.
<?phpecho strip_tags ("Hello <b>world!</b>");
Run results
Hello world!
3. function Htmlspecialchars, convert special characters to HTML format
The Htmlspecialchars () function converts pre-defined characters to HTML entities.
The predefined characters are:
& (and number) becomes &
"(double quotes) becomes"
' (single quote) become '
< (less than) becomes <
> (greater than) becomes >
<?phpecho Htmlspecialchars ("This is some <b>bold</b> text.&");
Run results
This is some <b>bold</b> text.&
4, function htmlentities, all the characters are converted to HTML string
Perhaps you are still sorry htmlspecialchars can only handle 4 HTML tags, so now you do not regret, htmlentities is to convert all characters.
<?phpecho htmlentities ("<? W3s?h???? > ");
Run results
<? W3s?h???? >
5. Addslashes, the function returns a string that adds a backslash before a predefined character.
The predefined characters are:
Single quotation mark (')
Double quotation marks (")
Back slash (\)
Null
<?phpecho addslashes (' Shanghai is the ' biggest ', City ');
Run results
Shanghai is the ' biggest\ City ' in China.
6. Stripslashes is a string that restores addslashes references.
<?phpecho stripslashes ("Who\ 's Bill Gates?");
Run results
Who ' s Bill Gates?
The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!