(Php 4, Php 5, Php 7, Php 8)
URLDECODE-Chuỗi được mã hóa URL được mã hóa — Decodes URL-encoded string
Sự mô tả
Urldecode (Chuỗi $string
): Chuỗi(string $string
): string
Thông số
string
Chuỗi được giải mã.
Trả về giá trị
Trả về chuỗi được giải mã.
Ví dụ
Ví dụ #1 urldecode () ví dụurldecode() example
<?php
$query = "my=apples&are=green+and+red";
foreach (
explode('&', $query) as $chunk) {
$param = explode("=", $chunk); if (
$param) {
printf("Value for parameter \"%s\" is \"%s\"<br/>\n", urldecode($param[0]), urldecode($param[1]));
}
}
?>
Ghi chú
Cảnh báo
Superglobals $ _Get và $ _Request đã được giải mã. Sử dụng urldecode () trên một phần tử trong $ _get hoặc $ _Request có thể có kết quả bất ngờ và nguy hiểm.urldecode() on an element in $_GET or
$_REQUEST could have unexpected and dangerous results.
Xem thêm
- urlencode () - Chuỗi mã hóa url
- RAWURLENCODE () - Mã điện tử URL theo RFC 3986
- RawUrldecode () - Chuỗi mã hóa URL giải mã
- »& NBSP; RFC 3986
Alejandro tại Devenet Dot Net ¶
11 năm trước
When the client send Get data, utf-8 character encoding have a tiny problem with the urlencode.
Consider the "º" character.
Some clients can send (as example)
foo.php?myvar=%BA
and another clients send
foo.php?myvar=%C2%BA (The "right" url encoding)
in this scenary, you assign the value into variable $x
<?php
$x = $_GET['myvar'];
?>
$x store: in the first case "�" (bad) and in the second case "º" (good)
To fix that, you can use this function:
<?php
function to_utf8( $string ) {
// From http://w3.org/International/questions/qa-forms-utf-8.html
if ( preg_match('%^(?:
[\x09\x0A\x0D\x20-\x7E] # ASCII
| [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
| \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
| [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
| \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
| \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
| [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
| \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
)*$%xs', $string) ) {
return $string;
} else {
return iconv( 'CP1252', 'UTF-8', $string);
}
}
?>
and assign in this way:
string
0
string
1
string
2
string
3
string
4
string
5
Trực quan ¶ ¶
16 năm trước
string
6
Jan Vratny ¶ ¶
14 năm trước
string
7
string
8
string
5 Tomas tại Penajaca dot com dot br ¶ ¶
19 năm trước
<?php
$query = "my=apples&are=green+and+red";
0
<?php
$query = "my=apples&are=green+and+red";
1
<?php
$query = "my=apples&are=green+and+red";
2
<?php
$query = "my=apples&are=green+and+red";
3
<?php
$query = "my=apples&are=green+and+red";
4
string
5
Matt Johnson ¶ ¶
17 năm trước
<?php
$query = "my=apples&are=green+and+red";
6
<?php
$query = "my=apples&are=green+and+red";
7
<?php
$query = "my=apples&are=green+and+red";
8
<?php
$query = "my=apples&are=green+and+red";
9
foreach (
0
foreach (
1
foreach (
2
foreach (
3
string
5 rosty dot kerei tại gmail dot com ¶ ¶
16 năm trước
foreach (
5
foreach (
6
foreach (
7
foreach (
8
foreach (
9
explode('&', $query) as $chunk) {
$param = explode("=", $chunk); if (
$param) {
printf("Value for parameter \"%s\" is \"%s\"<br/>\n", urldecode($param[0]), urldecode($param[1]));
}
}
?>
0
string
5 Jan Vratny ¶ ¶
14 năm trước
explode('&', $query) as $chunk) {
$param = explode("=", $chunk); if (
$param) {
printf("Value for parameter \"%s\" is \"%s\"<br/>\n", urldecode($param[0]), urldecode($param[1]));
}
}
?>
2
explode('&', $query) as $chunk) {
$param = explode("=", $chunk); if (
$param) {
printf("Value for parameter \"%s\" is \"%s\"<br/>\n", urldecode($param[0]), urldecode($param[1]));
}
}
?>
3
explode('&', $query) as $chunk) {
$param = explode("=", $chunk); if (
$param) {
printf("Value for parameter \"%s\" is \"%s\"<br/>\n", urldecode($param[0]), urldecode($param[1]));
}
}
?>
4 Tomas tại Penajaca dot com dot br ¶ ¶
14 năm trước
explode('&', $query) as $chunk) {
$param = explode("=", $chunk); if (
$param) {
printf("Value for parameter \"%s\" is \"%s\"<br/>\n", urldecode($param[0]), urldecode($param[1]));
}
}
?>
5
explode('&', $query) as $chunk) {
$param = explode("=", $chunk); if (
$param) {
printf("Value for parameter \"%s\" is \"%s\"<br/>\n", urldecode($param[0]), urldecode($param[1]));
}
}
?>
6
explode('&', $query) as $chunk) {
$param = explode("=", $chunk); if (
$param) {
printf("Value for parameter \"%s\" is \"%s\"<br/>\n", urldecode($param[0]), urldecode($param[1]));
}
}
?>
7
explode('&', $query) as $chunk) {
$param = explode("=", $chunk); if (
$param) {
printf("Value for parameter \"%s\" is \"%s\"<br/>\n", urldecode($param[0]), urldecode($param[1]));
}
}
?>
8
string
5 Tomas tại Penajaca dot com dot br ¶ ¶
19 năm trước
When the client send Get data, utf-8 character encoding have a tiny problem with the urlencode.
Consider the "º" character.
Some clients can send (as example)
foo.php?myvar=%BA
and another clients send
foo.php?myvar=%C2%BA (The "right" url encoding)
0
When the client send Get data, utf-8 character encoding have a tiny problem with the urlencode.
Consider the "º" character.
Some clients can send (as example)
foo.php?myvar=%BA
and another clients send
foo.php?myvar=%C2%BA (The "right" url encoding)
1
string
5 Matt Johnson ¶ ¶
19 năm trước
When the client send Get data, utf-8 character encoding have a tiny problem with the urlencode.
Consider the "º" character.
Some clients can send (as example)
foo.php?myvar=%BA
and another clients send
foo.php?myvar=%C2%BA (The "right" url encoding)
3
When the client send Get data, utf-8 character encoding have a tiny problem with the urlencode.
Consider the "º" character.
Some clients can send (as example)
foo.php?myvar=%BA
and another clients send
foo.php?myvar=%C2%BA (The "right" url encoding)
4
When the client send Get data, utf-8 character encoding have a tiny problem with the urlencode.
Consider the "º" character.
Some clients can send (as example)
foo.php?myvar=%BA
and another clients send
foo.php?myvar=%C2%BA (The "right" url encoding)
5
string
5 Matt Johnson ¶ ¶
17 năm trước
When the client send Get data, utf-8 character encoding have a tiny problem with the urlencode.
Consider the "º" character.
Some clients can send (as example)
foo.php?myvar=%BA
and another clients send
foo.php?myvar=%C2%BA (The "right" url encoding)
7
rosty dot kerei tại gmail dot com ¶ ¶
14 năm trước
When the client send Get data, utf-8 character encoding have a tiny problem with the urlencode.
Consider the "º" character.
Some clients can send (as example)
foo.php?myvar=%BA
and another clients send
foo.php?myvar=%C2%BA (The "right" url encoding)
8
When the client send Get data, utf-8 character encoding have a tiny problem with the urlencode.
Consider the "º" character.
Some clients can send (as example)
foo.php?myvar=%BA
and another clients send
foo.php?myvar=%C2%BA (The "right" url encoding)
9
in this scenary, you assign the value into variable $x
0
in this scenary, you assign the value into variable $x
1
string
5 Tomas tại Penajaca dot com dot br ¶ ¶
17 năm trước
in this scenary, you assign the value into variable $x
3
in this scenary, you assign the value into variable $x
4
in this scenary, you assign the value into variable $x
5
in this scenary, you assign the value into variable $x
6
in this scenary, you assign the value into variable $x
7
in this scenary, you assign the value into variable $x
8
in this scenary, you assign the value into variable $x
9
<?php
$x = $_GET['myvar'];
?>
$x store: in the first case "�" (bad) and in the second case "º" (good)
0
string
5 rosty dot kerei tại gmail dot com ¶ ¶
Ozlperez11 tại gmail dot com ¶
<?php
$x = $_GET['myvar'];
?>
$x store: in the first case "�" (bad) and in the second case "º" (good)
2
<?php
$x = $_GET['myvar'];
?>
$x store: in the first case "�" (bad) and in the second case "º" (good)
3
<?php
$x = $_GET['myvar'];
?>
$x store: in the first case "�" (bad) and in the second case "º" (good)
4
<?php
$x = $_GET['myvar'];
?>
$x store: in the first case "�" (bad) and in the second case "º" (good)
5
<?php
$x = $_GET['myvar'];
?>
$x store: in the first case "�" (bad) and in the second case "º" (good)
6
string
5
7 năm trước ¶
19 năm trước
<?php
$x = $_GET['myvar'];
?>
$x store: in the first case "�" (bad) and in the second case "º" (good)
8
Matt Johnson ¶ ¶
17 năm trước
<?php
$x = $_GET['myvar'];
?>
$x store: in the first case "�" (bad) and in the second case "º" (good)
9
To fix that, you can use this function:
0
To fix that, you can use this function:
1
To fix that, you can use this function:
2
string
5 rosty dot kerei tại gmail dot com ¶ ¶
19 năm trước
To fix that, you can use this function:
4
To fix that, you can use this function:
5
To fix that, you can use this function:
6
To fix that, you can use this function:
7
To fix that, you can use this function:
8
To fix that, you can use this function:
9
<?php
function to_utf8( $string ) {
// From http://w3.org/International/questions/qa-forms-utf-8.html
if ( preg_match('%^(?:
[\x09\x0A\x0D\x20-\x7E] # ASCII
| [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
| \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
| [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
| \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
| \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
| [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
| \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
)*$%xs', $string) ) {
return $string;
} else {
return iconv( 'CP1252', 'UTF-8', $string);
}
}
?>
and assign in this way:
0
<?php
function to_utf8( $string ) {
// From http://w3.org/International/questions/qa-forms-utf-8.html
if ( preg_match('%^(?:
[\x09\x0A\x0D\x20-\x7E] # ASCII
| [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
| \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
| [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
| \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
| \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
| [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
| \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
)*$%xs', $string) ) {
return $string;
} else {
return iconv( 'CP1252', 'UTF-8', $string);
}
}
?>
and assign in this way:
1
string
5 Matt Johnson ¶ ¶
19 năm trước
<?php
function to_utf8( $string ) {
// From http://w3.org/International/questions/qa-forms-utf-8.html
if ( preg_match('%^(?:
[\x09\x0A\x0D\x20-\x7E] # ASCII
| [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
| \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
| [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
| \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
| \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
| [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
| \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
)*$%xs', $string) ) {
return $string;
} else {
return iconv( 'CP1252', 'UTF-8', $string);
}
}
?>
and assign in this way:
3
<?php
function to_utf8( $string ) {
// From http://w3.org/International/questions/qa-forms-utf-8.html
if ( preg_match('%^(?:
[\x09\x0A\x0D\x20-\x7E] # ASCII
| [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
| \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
| [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
| \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
| \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
| [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
| \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
)*$%xs', $string) ) {
return $string;
} else {
return iconv( 'CP1252', 'UTF-8', $string);
}
}
?>
and assign in this way:
4
string
5Matt Johnson ¶ ¶
19 năm trước
<?php
function to_utf8( $string ) {
// From http://w3.org/International/questions/qa-forms-utf-8.html
if ( preg_match('%^(?:
[\x09\x0A\x0D\x20-\x7E] # ASCII
| [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
| \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
| [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
| \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
| \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
| [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
| \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
)*$%xs', $string) ) {
return $string;
} else {
return iconv( 'CP1252', 'UTF-8', $string);
}
}
?>
and assign in this way:
6
<?php
function to_utf8( $string ) {
// From http://w3.org/International/questions/qa-forms-utf-8.html
if ( preg_match('%^(?:
[\x09\x0A\x0D\x20-\x7E] # ASCII
| [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
| \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
| [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
| \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
| \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
| [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
| \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
)*$%xs', $string) ) {
return $string;
} else {
return iconv( 'CP1252', 'UTF-8', $string);
}
}
?>
and assign in this way:
7
<?php
function to_utf8( $string ) {
// From http://w3.org/International/questions/qa-forms-utf-8.html
if ( preg_match('%^(?:
[\x09\x0A\x0D\x20-\x7E] # ASCII
| [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
| \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
| [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
| \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
| \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
| [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
| \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
)*$%xs', $string) ) {
return $string;
} else {
return iconv( 'CP1252', 'UTF-8', $string);
}
}
?>
and assign in this way:
8
string
5Giải mã từ định dạng được mã hóa URL.Chỉ cần nhập dữ liệu của bạn sau đó nhấn nút giải mã.Đối với các nhị phân được mã hóa (như hình ảnh, tài liệu, v.v.) sử dụng tệp tải lên trên mẫu thêm một chút trên trang này.Bộ ký tự nguồn.Simply enter your data then push the decode button. For encoded binaries (like images, documents, etc.) use the file upload form a little further down on this page. Source character set.
PHP |hàm urlencode ().Hàm urlencode () là một hàm sẵn có trong PHP được sử dụng để mã hóa URL.Hàm này trả về một chuỗi bao gồm tất cả các ký tự không phải là số đồnguman ngoại trừ -_.và thay thế bằng phần trăm (%) theo sau là hai chữ số hex và khoảng trống được mã hóa dưới dạng dấu cộng (+).urlencode() Function. The urlencode() function is an inbuilt function in PHP which is used to encode the url. This function returns a string which consist all non-alphanumeric characters except -_. and replace by the percent (%) sign followed by two hex digits and spaces encoded as plus (+) signs.
Tuy nhiên, câu hỏi là, tại sao nó được sử dụng?Các chuỗi URL mã hóa và giải mã được sử dụng để chuyển đổi các chuỗi và ký tự URL chung thành một sự sắp xếp có thể được chuyển qua internet.Trong hướng dẫn này, bạn sẽ tìm hiểu về hai cách trong đó chuỗi URL có thể được mã hóa và giải mã trong PHP.used to convert general URL strings and characters into an arrangement that can be conveyed over the internet. In this tutorial, you will learn about two ways in which URL string can be encoded and decoded in PHP.