PHP urlencode - PHP urlencode can be used to encode strings

 PHP urlencode can be used to encode strings. Since we are using Traditional Chinese, PHP will have problems when transferring data directly to Traditional Chinese. Therefore, when transferring data, we usually use urlencode to encode first and then transfer it. Especially URL strings.


PHP urlencode syntax example

string urlencode (the string to be encoded or the entire URL);


With the urlencode function, URL parameters or the entire URL can be conveniently used as a side code, and it is also convenient to pass to the next page or running program.

PHP urlencode implementation example
<?php
 $url='http://www.wibibi.com';
 echo urlencode($url);
?>
Output result: http%3A%2F%2Fwww.wibibi.com

From the output result, you can see that the URL of the URL is encoded as %3A%2F%2F, so the webpage may not be displayed smoothly on the browser after encoding, so The next page also needs to perform the decoding action, the decoding can use urldecode to restore the URL and it can be displayed smoothly.

It is also worth noting that &, © and £ will be parsed by the browser, please refer to the W3C instructions.

B.2.2 Ampersands in URI attribute values
http://www.w3.org/TR/html4/appendix/notes.html#hB.2.2

Post a Comment

0 Comments