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

PHP Home Page

Manual Table of Contents
Up to Chaînes
Quick Reference
English version of this pageGerman version of this pageJapanese version of this pageItalian version of this pageHungarian version of this page
Chaînes
* AddCSlashes
* AddSlashes
* bin2hex
* Chop
* Chr
* chunk_split
* convert_cyr_string
* count_chars
* crypt
* echo
* explode
* flush
* get_html_translation_table
* get_meta_tags
* htmlentities
* htmlspecialchars
* implode
* join
* ltrim
* md5
* Metaphone
* nl2br
* Ord
* parse_str
* print
* printf
* quoted_printable_decode
* QuoteMeta
* rawurldecode
* rawurlencode
* setlocale
* similar_text
* soundex
* sprintf
* strcasecmp
* strchr
* strcmp
* strcspn
* strip_tags
* StripCSlashes
* StripSlashes
* stristr
* strlen
* strpos
* strrchr
* str_repeat
* strrev
* strrpos
* strspn
* strstr
* strtok
* strtolower
* strtoupper
* str_replace
* strtr
* substr
* substr_replace
* trim
* ucfirst
* ucwords
Manual: rawurlencode
View the source code for this pageSearch the site



Previous page
 rawurldecode
 Updated
Sun, 06 Aug 2000
setlocale 
Next page


rawurlencode

(PHP3 , PHP4 )

rawurlencode -- Encode une chaîne en URL, selon la RFC1738.

Description

string rawurlencode (string str)

Retourne une chaîne dont tous les caractères non-alpha-numériques (hormis
-_.
.) auront été remplacés par des séquences %xy (%), avec xy deux valeurs hexadécimales. Ce codage est conforme à la RFC1738 qui évite que les caractères spéciaux soient interprétés comme des délimiteurs, et pour protéger les URL lors du transfert (contrairement à certains systèmes email). Par exemple, si vous voulez mettre un mot de passe dans une URL de ftp :

Exemple 1. Exemple avec Rawurlencode() example 1


echo '<A HREF="ftp://user:', rawurlencode ('foo @+%/'),
     '@ftp.my.com/x.txt">';
      
Ou, si vous transmettez un chemin dans une URL

Exemple 2. Exemple avec Rawurlencode() example 2


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

Voir aussi rawurldecode().


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%2Ffr%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
Sun, 06 Aug 2000
setlocale 
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.