★ wanayoo — archive 1999 http://www.php.net/manual/function.rawurlencode.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to URLs
Quick Reference
German version of this pageJapanese version of this pageItalian version of this pageFrench version of this pageHungarian version of this page
URLs
* base64_decode
* base64_encode
* parse_url
* rawurldecode
* rawurlencode
* urldecode
* urlencode
Manual: rawurlencode
View the source code for this pageSearch the site



Previous page
 rawurldecode
 Updated
Sat, 12 Aug 2000
urldecode 
Next page


rawurlencode

(PHP3 , PHP4 )

rawurlencode -- URL-encode according to RFC1738

Description

string rawurlencode (string str)

Returns a string in which all non-alphanumeric characters except
-_.
have been replaced with a percent (%) sign followed by two hex digits. This is the encoding described in RFC1738 for protecting literal characters from being interpreted as special URL delimiters, and for protecting URL's from being mangled by transmission media with character conversions (like some email systems). For example, if you want to include a password in an ftp url:

Example 1. Rawurlencode() example 1


echo '<A HREF="ftp://user:', rawurlencode ('foo @+%/'),
     '@ftp.my.com/x.txt">';
      
Or, if you pass information in a path info component of the url:

Example 2. Rawurlencode() example 2


echo '<A HREF="http://x.com/department_list_script/',
    rawurlencode ('sales and marketing/Miami'), '">';
      

See also rawurldecode(), urldecode(), urlencode().


User Contributed Notes: rawurlencode


martin@inmeco.de
12-Apr-2000 07:35
There may occour a serious problem if the processed string contains percent-characters itself. They are _NOT_ converted at all!
If those <PRE>%</PRE> are followed by any characters that may be interpreted as a hexadecimal value, an rawurldecode will mis-interpret them.

For example an
<PRE>print rawurldecode(rawurlencode("%berg%"));</PRE>
leads to the output
&frac34;rg%

The only workaround I found is to convert those characters manually for example with
<PRE>
$a = rawurlencode(ereg_replace("%", "%25", "%berg%"));
print rawurldecode $a;
</PRE>

which leads to the correct result
%berg%



cnagele@maneo.com
20-Apr-2000 08:08
Why can does rawurlencode() not work in Internet Explorer? It works fine with netscape.


daniel@pi.se
14-Jul-2000 12:42
rawurlencode doesn't work properly on Internet Explorer 5.0 but works fine in Netscape. Explorer must rewrite the HTML code that it gets from the server in some way?


PDR813@beer.com
14-Jul-2000 04:19
urlencode cant process php variables using their value ie: <pre>
$var="foo's bar";
echo "<a href=/old?u=http%3A%2F%2Fwww.php.net%2Fmanual%2F%5C%26quot%3Blogin.phtml%3Fname%3D%26quot%3B%2C&y=1999 urlencode('$var'), "\">";
</pre>
$name will have the value '$var' on login.phtml
any way arounf this ? ? ? i want to pass php variables with spaces in them in the URL can anyone help ?



powerlord@vgmusic.com
28-Jul-2000 06:08
Try rawurlencode($var) instead of rawurlencode('$var')


jonathan@wycombe-online.net
03-Aug-2000 03:44
In response to PDR813@beer.com, the reason why variable substitution is not working for you is that you are using single quotes ('). PHP only does variable substitution for double quotes ("). RTFM.


 About Notes


Previous page
 rawurldecode
 Updated
Sat, 12 Aug 2000
urldecode 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.