How do I escape an ampersand in a url?

stocks

New Member
Messages
22
Reaction score
0
Points
0
I want to use file_get_contents to read a url, but it can't read the second arg because it seems to stop at the ampersand.
 

Zenax

Active Member
Messages
1,377
Reaction score
4
Points
38
why not mask the orignal URL with one from tinyurl.com

it will make the string shorter but also remove any unwanted ampersands. The URL will still load. Try it and see...
 

Catzwolf

New Member
Messages
11
Reaction score
0
Points
0
First not sure why you are using that method to gey the adress of a url, but the answer to your problem is:

Code:
$url = htmlspecialchars( $url );
 

shaunak

New Member
Messages
320
Reaction score
0
Points
0
Answer to your question...
& escapes as %26
 
Last edited:
Top