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
<?php $str = "w3cschool你好"; echo '<a href="w3cschool?foo='. urlencode($str). '">'; ?>
The above code will output:
<a href="w3cschool?foo=w3cschool%E4%BD%A0%E5%A5%BD">
[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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

WebStorm Mac version
Useful JavaScript development tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Mac version
God-level code editing software (SublimeText3)
