Hướng dẫn does php automatically decode url? - php có tự động giải mã url không?

(Php 4, Php 5, Php 7, Php 8)

URLDECODE-Chuỗi được mã hóa URL được mã hóaDecodes 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

$query "my=apples&are=green+and+red";

foreach (

explode('&'$query) as $chunk) {
    
$param explode("="$chunk);

    if (

$param) {
        
printf("Value for parameter \"%s\" is \"%s\"
\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

$x = $_GET['myvar'];
?>

$x store: in the first case "�" (bad) and in the second case "º" (good)

To fix that, you can use this function:

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:

string0

string1

string2

string3

string4

string5

Trực quan ¶

16 năm trước

string6

Jan Vratny ¶

14 năm trước

string7

string8

string5

Tomas tại Penajaca dot com dot br ¶

19 năm trước

$query "my=apples&are=green+and+red";0

$query "my=apples&are=green+and+red";1

$query "my=apples&are=green+and+red";2

$query "my=apples&are=green+and+red";3

$query "my=apples&are=green+and+red";4

string5

Matt Johnson ¶

17 năm trước

$query "my=apples&are=green+and+red";6

$query "my=apples&are=green+and+red";7

$query "my=apples&are=green+and+red";8

$query "my=apples&are=green+and+red";9

foreach (0

foreach (1

foreach (2

foreach (3

string5

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\"
\n"
urldecode($param[0]), urldecode($param[1]));
    }
}
?>
0

string5

Jan Vratny ¶

14 năm trước

explode('&'$query) as $chunk) {
    
$param explode("="$chunk);

    if (

$param) {
        
printf("Value for parameter \"%s\" is \"%s\"
\n"
urldecode($param[0]), urldecode($param[1]));
    }
}
?>
2

explode('&'$query) as $chunk) {
    
$param explode("="$chunk);

    if (

$param) {
        
printf("Value for parameter \"%s\" is \"%s\"
\n"
urldecode($param[0]), urldecode($param[1]));
    }
}
?>
3

explode('&'$query) as $chunk) {
    
$param explode("="$chunk);

    if (

$param) {
        
printf("Value for parameter \"%s\" is \"%s\"
\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\"
\n"
urldecode($param[0]), urldecode($param[1]));
    }
}
?>
5

explode('&'$query) as $chunk) {
    
$param explode("="$chunk);

    if (

$param) {
        
printf("Value for parameter \"%s\" is \"%s\"
\n"
urldecode($param[0]), urldecode($param[1]));
    }
}
?>
6

explode('&'$query) as $chunk) {
    
$param explode("="$chunk);

    if (

$param) {
        
printf("Value for parameter \"%s\" is \"%s\"
\n"
urldecode($param[0]), urldecode($param[1]));
    }
}
?>
7

explode('&'$query) as $chunk) {
    
$param explode("="$chunk);

    if (

$param) {
        
printf("Value for parameter \"%s\" is \"%s\"
\n"
urldecode($param[0]), urldecode($param[1]));
    }
}
?>
8

string5

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

string5

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

string5

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

string5

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

$x = $_GET['myvar'];
?>

$x store: in the first case "�" (bad) and in the second case "º" (good)
0

string5

rosty dot kerei tại gmail dot com ¶

Ozlperez11 tại gmail dot com ¶

$x = $_GET['myvar'];
?>

$x store: in the first case "�" (bad) and in the second case "º" (good)
2

$x = $_GET['myvar'];
?>

$x store: in the first case "�" (bad) and in the second case "º" (good)
3

$x = $_GET['myvar'];
?>

$x store: in the first case "�" (bad) and in the second case "º" (good)
4

$x = $_GET['myvar'];
?>

$x store: in the first case "�" (bad) and in the second case "º" (good)
5

$x = $_GET['myvar'];
?>

$x store: in the first case "�" (bad) and in the second case "º" (good)
6

string5

7 năm trước

19 năm trước

$x = $_GET['myvar'];
?>

$x store: in the first case "�" (bad) and in the second case "º" (good)
8

Matt Johnson ¶

17 năm trước

$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

string5

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

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

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

string5

Matt Johnson ¶

19 năm trước

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

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

string5

Matt Johnson ¶

19 năm trước

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

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

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

string5

Là URL

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 (+).. 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.

Làm thế nào để tôi giải mã một url?

Giả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.

Trình duyệt có tự động giải mã URL không?

Các thông số truy vấn cũng phải được mã hóa trong chuỗi URL, trong đó máy chủ sẽ giải mã điều này.Nhiều trình duyệt tự động mã hóa và giải mã URL và chuỗi phản hồi.Ví dụ: một không gian "" được mã hóa dưới dạng A + hoặc %20.Many browsers automatically encode and decode the URL and the response string. E.g., A space " " is encoded as a + or %20.

Làm thế nào giải mã URL trong PHP?

Hàm urldecode () là một hàm sẵn có trong PHP được sử dụng để giải mã URL được mã hóa bởi hàm được mã hóa ().Tham số: Hàm này chấp nhận thông số $ đầu vào giữ URL được giải mã.Giá trị trả về: Hàm này trả về chuỗi được giải mã khi thành công.urldecode() function is an inbuilt function in PHP which is used to decode url which is encoded by encoded() function. Parameters: This function accepts single parameter $input which holds the url to be decoded. Return Value: This function returns the decoded string on success.