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

PHP Home Page

Manual Table of Contents
Up to URLs
Quick Reference
English version of this pageGerman 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
Mon, 14 Aug 2000
urldecode 
Next page


rawurlencode

(PHP3 , PHP4 )

rawurlencode -- RFC1738に基づきURLエンコードを行う

説明

string rawurlencode (string str)

-_.
を除くすべての非アルファベット文字をパーセント記号 (%)に続いて2つの16進数がある表現形式に置き換えた文字列 を返します。これは、文字定数が特殊なURLデリミタとして解釈されたり、 URL デリミタが(いくつかの電子メールシステムのような)転送メディア により文字変換されて失われてしまったりすることがないように、 RFC1738で定められたエンコーディング方法です。たとえば、FTP のURLに中にパスワードを埋め込みたい場合は以下のようにします。

例 1. rawurlencode() の例1


echo '<A HREF="ftp://user:', rawurlencode ('foo @+%/'),
     '@ftp.my.com/x.txt">';
      
また、URLの一部としてパス情報を渡す場合は、

例 2. rawurlencode() の例2


echo '<A HREF="http://x.com/department_list_script/',
     rawurlencode ('sales and marketing/Miami'), '">';
      
のようにします。

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%2Fja%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
Mon, 14 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.