Hi all,

I have seen an strange thing with the funcion Header("Location: $url")
and will tell in short words.

I have a method in a class wich composes an URL from the database,
this method sets some extra params in the url. In this case, the
function returns:

/myaccount/?opt=sys&id=3

Note the & in the URL

Well, with this code, the url works perfect and the & is going as
expected redirecting to /myaccount/?opt=sys&id=3

echo '<a href="'. $url .'">Test URL</a>';

But when triying 

header("Location: $url");

What I get is address is literally the &amp; string and not the & char. 
I supose this is because the header() function literally writes the
string as new address without translating the html entities.

The only solution I've found is to change the code to this:

header('Location: '. html_entity_decode($url));

I would like to know if there is a better way to do it, or something
else I should take into consideration.

Thanks to all for reading,
Jordi Canals

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to