php The urlencode function is used to encode a string and use it in the request part of the URL. It also facilitates passing variables to the next page. Its usage syntax is "string urlencode(string $str)" , the parameter str represents the string to be encoded.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
urlencode() encoding URL string function .
This function facilitates encoding a string and using it in the request part of the URL, and it also facilitates passing variables to the next page.
We often use this function to encode Chinese strings in URLs to avoid errors in URL calls.
Related functions: urldecode() function, decoding URL string function.
Syntax
string urlencode ( string $str )
Parameters
str The string to be encoded
Note:
Note: Be careful with variables matching HTML entities. Characters like &, ©, and £ will all be parsed by the browser and replace the expected variable name with the actual entity. This is obvious confusion, and the W3C has been warning people about it for several years.
Example
'; ?>
The above code will output:
[Recommended learning: "PHP Video Tutorial"]
The above is the detailed content of Usage of php urlencode function. For more information, please follow other related articles on the PHP Chinese website!