Usage of php urlencode function

藏色散人
Release: 2023-03-08 13:22:01
Original
2199 people have browsed it

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.

Usage of php urlencode function

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 )
Copy after login

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

'; ?>
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!