php urlencode and rawurlencode tutorial_PHP tutorial

WBOY
Release: 2016-07-13 17:03:59
Original
852 people have browsed it

php urlencode and rawurlencode tutorial rawurlencode
(PHP 4, PHP 5)

rawurlencode - URL encoding according to RFC 1738

Description
String rawurlencode (String $str)
Encode a specific string according to » RFC 1738.

Parameters

str
Encode the URL.


Return value
Returns all non-alphanumeric characters in a string except - _. is replaced with a percent sign ( % ) followed by two hexadecimal digits. This is the encoding description » RFC 1738 for protecting literal characters from being interpreted as special URL delimiters and protecting URLs from being mangled in transmissions with media conversion properties (such as some email systems).

Example

Example #1 includes a password for the FTP URL

$a = explode('&', $QUERY_STRING);
$i = 0;
while ($i < count($a)) {
$b = split('=', $a[$i]);
echo 'Value for parameter ', htmlspecialchars(urldecode($b[0])),
' is ', htmlspecialchars(urldecode($b[1])), "
n";
$i++;
}
?>

Urlencode
(PHP 4, PHP 5)

do urlencode - URL encoded string

Description
String urlencode (String $str)
This feature conveniently encodes a string that is used as part of a query's URL, as a convenient way to pass variables to the next page.

Parameters

str
String encoding.


Return value
Returns all non-alphanumeric characters in a string except - _. is replaced with a percent sign ( % ) sign followed by two hexadecimal digits and spaces encoded as a plus sign ( + ) sign. This is the same way the published data is encoded from the www-form, and it is the same way the urlencoded media type is in the application/x-www-form. This differs from the reference » RFC 1738 encoding (see rawurlencode()), which for historical reasons encodes spaces as plus (+) signs.

Example

Example #1 Example of urlencode()

echo '';
?>


Example #2 urlencode() and htmlentities() example

$query_string = 'foo=' . urlencode($foo) . '&bar=' . urlencode($bar);
echo '
';
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/630888.htmlTechArticlephp urlencode and rawurlencode tutorial rawurlencode (PHP 4, PHP 5) rawurlencode - URL encoding according to RFC 1738 description String rawurlencode (String $str) Encoding specific...
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
Popular Tutorials
More>
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!