(Php 4, Php 5, Php 7, Php 8)
URLENCODE-Chuỗi mã hóa url — URL-encodes string
Sự mô tả
urlencode (Chuỗi $string): Chuỗi(string $string): string
Thông số
stringChuỗi được mã hóa.
Trả về giá trị
Trả về một chuỗi trong đó tất cả các ký tự không phải là số đồngumeric ngoại trừ -_. đã được thay thế bằng một dấu hiệu phần trăm (%) theo sau là hai chữ số hex và không gian được mã hóa dưới dạng các dấu hiệu cộng (+). Nó được mã hóa giống như cách dữ liệu được đăng từ biểu mẫu WWW được mã hóa, đó là cách tương tự như trong loại phương tiện application/x-www-form-urlencoded. Điều này khác với mã hóa »& nbsp; rfc 3986 (xem RawUrlenCode ()) trong đó vì lý do lịch sử, không gian được mã hóa dưới dạng các dấu hiệu cộng (+).rawurlencode()) in that for historical reasons, spaces are encoded as plus (+) signs.
Ví dụ
Ví dụ #1 urlencode () ví dụurlencode() example
<?php
echo '<a href="mycgi?foo=', urlencode($userinput), '">';
?>
Ví dụ #2 urlencode () và htmlentities () ví dụurlencode() and htmlentities() example
<?php
$query_string = 'foo=' . urlencode($foo) . '&bar=' . urlencode($bar);
echo '<a href="mycgi?' . htmlentities($query_string) . '">';
?>
Ghi chú
Ghi chú::
Hãy cẩn thận về các biến có thể phù hợp với các thực thể HTML. Những thứ như & amp, & copy và & pound được phân tích cú pháp bởi trình duyệt và thực thể thực tế được sử dụng thay vì tên biến mong muốn. Đây là một rắc rối rõ ràng mà W3C đã nói với mọi người trong nhiều năm. Tài liệu tham khảo ở đây: »& nbsp; //www.w3.org/tr/html4/appendix/notes.html#h-b.2.2.
PHP hỗ trợ thay đổi bộ phân cách đối số thành đại hội bán hàng W3C thông qua chỉ thị arg_separator .ini. Thật không may, hầu hết các đại lý người dùng không gửi dữ liệu biểu mẫu ở định dạng phân tách bán chính này. Một cách di động hơn xung quanh việc này là sử dụng & amp; thay vì & là dấu phân cách. Bạn không cần phải thay đổi arg_separator của PHP cho việc này. Để nó như &, nhưng chỉ cần mã hóa URL của bạn bằng HTMLEntities () hoặc HTMLSpecialchars ().htmlentities() or htmlspecialchars().
Xem thêm
- Urldecode () - Chuỗi được mã hóa url được mã hóa
- HTMLENTITY () - Chuyển đổi tất cả các ký tự áp dụng thành các thực thể HTML
- RAWURLENCODE () - Mã điện tử URL theo RFC 3986
- RawUrldecode () - Chuỗi mã hóa URL giải mã
- »& NBSP; RFC 3986
Davis Dot Peixoto tại Gmail Dot Com ¶ ¶
12 năm trước
urlencode function and rawurlencode are mostly based on RFC 1738.
However, since 2005 the current RFC in use for URIs standard is RFC 3986.
string0
string1
string2Temu92 tại Gmail Dot Com ¶ ¶
13 năm trước
string3
string4
string5
string6omid tại omidsakhi dot com ¶
12 năm trước
string7
string8
string2Temu92 tại Gmail Dot Com ¶ ¶
13 năm trước
-_.0
-_.1
string2omid tại omidsakhi dot com ¶
Daniel+PHP tại Danielnorton Dot Com ¶
-_.3
-_.4
-_.5
-_.6
-_.7
-_.8
-_.9
%0
%1
%2
%3
string2Izhankhalib tại gmail dot com ¶ ¶
8 năm trước
%5
%6
%7
%8
string2lekiagospel@gmail dot com ¶ ¶
1 năm trước
+0
David Winiecki Gmail ¶ ¶
7 năm trước
+1
+2
+3
+4
+5Ahrensberg tại gmail dot com ¶ ¶
15 năm trước
+6
+7
+8
+9
KL ¶16 năm trước ¶
application/x-www-form-urlencoded0
application/x-www-form-urlencoded1
application/x-www-form-urlencoded2
application/x-www-form-urlencoded3
application/x-www-form-urlencoded4
application/x-www-form-urlencoded5
application/x-www-form-urlencoded6
string2yohanasobhy15 tại gmail dot com ¶ ¶
12 năm trước
application/x-www-form-urlencoded8
application/x-www-form-urlencoded9
<?php
echo '<a href="mycgi?foo=', urlencode($userinput), '">';
?>
0
Temu92 tại Gmail Dot Com ¶ ¶
13 năm trước
<?php
echo '<a href="mycgi?foo=', urlencode($userinput), '">';
?>
2
<?php
echo '<a href="mycgi?foo=', urlencode($userinput), '">';
?>
3
<?php
echo '<a href="mycgi?foo=', urlencode($userinput), '">';
?>
4
omid tại omidsakhi dot com ¶
Daniel+PHP tại Danielnorton Dot Com ¶
<?php
echo '<a href="mycgi?foo=', urlencode($userinput), '">';
?>
6
Izhankhalib tại gmail dot com ¶ ¶
8 năm trước
<?php
echo '<a href="mycgi?foo=', urlencode($userinput), '">';
?>
7
<?php
echo '<a href="mycgi?foo=', urlencode($userinput), '">';
?>
8
<?php
echo '<a href="mycgi?foo=', urlencode($userinput), '">';
?>
9
lekiagospel@gmail dot com ¶ ¶
1 năm trước
<?php
$query_string = 'foo=' . urlencode($foo) . '&bar=' . urlencode($bar);
echo '<a href="mycgi?' . htmlentities($query_string) . '">';
?>
1
<?php
$query_string = 'foo=' . urlencode($foo) . '&bar=' . urlencode($bar);
echo '<a href="mycgi?' . htmlentities($query_string) . '">';
?>
2
<?php
$query_string = 'foo=' . urlencode($foo) . '&bar=' . urlencode($bar);
echo '<a href="mycgi?' . htmlentities($query_string) . '">';
?>
3
David Winiecki Gmail ¶ ¶
7 năm trước
<?php
$query_string = 'foo=' . urlencode($foo) . '&bar=' . urlencode($bar);
echo '<a href="mycgi?' . htmlentities($query_string) . '">';
?>
5
<?php
$query_string = 'foo=' . urlencode($foo) . '&bar=' . urlencode($bar);
echo '<a href="mycgi?' . htmlentities($query_string) . '">';
?>
6
<?php
$query_string = 'foo=' . urlencode($foo) . '&bar=' . urlencode($bar);
echo '<a href="mycgi?' . htmlentities($query_string) . '">';
?>
7
<?php
$query_string = 'foo=' . urlencode($foo) . '&bar=' . urlencode($bar);
echo '<a href="mycgi?' . htmlentities($query_string) . '">';
?>
8
<?php
$query_string = 'foo=' . urlencode($foo) . '&bar=' . urlencode($bar);
echo '<a href="mycgi?' . htmlentities($query_string) . '">';
?>
9
Ahrensberg tại gmail dot com ¶ ¶
13 năm trước
urlencode function and rawurlencode are mostly based on RFC 1738.1
urlencode function and rawurlencode are mostly based on RFC 1738.2
urlencode function and rawurlencode are mostly based on RFC 1738.3
urlencode function and rawurlencode are mostly based on RFC 1738.4
urlencode function and rawurlencode are mostly based on RFC 1738.5
urlencode function and rawurlencode are mostly based on RFC 1738.6omid tại omidsakhi dot com ¶
8 năm trước
urlencode function and rawurlencode are mostly based on RFC 1738.7
urlencode function and rawurlencode are mostly based on RFC 1738.8
urlencode function and rawurlencode are mostly based on RFC 1738.9
However, since 2005 the current RFC in use for URIs standard is RFC 3986.0
However, since 2005 the current RFC in use for URIs standard is RFC 3986.1
However, since 2005 the current RFC in use for URIs standard is RFC 3986.2
lekiagospel@gmail dot com ¶1 năm trước ¶
Daniel+PHP tại Danielnorton Dot Com ¶
However, since 2005 the current RFC in use for URIs standard is RFC 3986.4
However, since 2005 the current RFC in use for URIs standard is RFC 3986.5
However, since 2005 the current RFC in use for URIs standard is RFC 3986.6
However, since 2005 the current RFC in use for URIs standard is RFC 3986.7
However, since 2005 the current RFC in use for URIs standard is RFC 3986.8
string2Izhankhalib tại gmail dot com ¶ ¶
15 năm trước
string00
string01
string02
string03
string2KL ¶ ¶
Daniel+PHP tại Danielnorton Dot Com ¶
string05
string06
string07
string08Izhankhalib tại gmail dot com ¶ ¶
8 năm trước
string09
string10
string11
string12
string13lekiagospel@gmail dot com ¶ ¶
Daniel+PHP tại Danielnorton Dot Com ¶
string14
string15
string16
string17
string18
string19
string20
string2