I am trying to change the blank spaces in my url's to %20 with the rawurlencode function. When I hover over a hyperlink the status bar will show the correct hyperlink like http://test/test%20page, but when I click on the hyperlink I am prompted to open the page with a program because windows doesn't seem to recognize the extension. I will then choose Internet Explorer to open the page and I get an error explaining that the page cannot be opened and the hyperlink that I described earlier will be shown as http://test/test%2520page. There will be a 25 thrown in between the % sign and the # 20. Thanks for your help.
rawurlencode() problem
Moderator: General Moderators
rawurlencode() problem
I am trying to change the blank spaces in my url's to %20 with the rawurlencode function. When I hover over a hyperlink the status bar will show the correct hyperlink like http://test/test%20page, but when I click on the hyperlink I am prompted to open the page with a program because windows doesn't seem to recognize the extension. I will then choose Internet Explorer to open the page and I get an error explaining that the page cannot be opened and the hyperlink that I described earlier will be shown as http://test/test%2520page. There will be a 25 thrown in between the % sign and the # 20. Thanks for your help.
There is no extension to page. Try dis:
Code: Select all
$urlo="http://www.test.com/test page.html";
$newurl=rawurlencode("$urlo");
echo "$newurl";
//should output http://www.test.com/test%20page.htmlSorry about that, bad example. What I am really trying to navigate to is a folder that exist somewhere in my site directory. Like test folder.
so my hyperlink would look like http://test/test folder normally
and I want http://test/test%20folder
but I keep getting http://test/test%2520folder.
Thanks again for your help
so my hyperlink would look like http://test/test folder normally
and I want http://test/test%20folder
but I keep getting http://test/test%2520folder.
Thanks again for your help
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Of course the obvious answer is to not use spaces in your file or folder names because it causes more hassles than it's worth (underscores work just as well).
For the problem in hand though, it looks like the url is being encoded twice - %25 is the urlencoding for the % symbol - check the output of:
Mac
For the problem in hand though, it looks like the url is being encoded twice - %25 is the urlencoding for the % symbol - check the output of:
Code: Select all
<?php
$url = 'test folder';
echo rawurlencode(rawurlencode($url));
?>