Re: Extrange behavior with Header('Location')

From: Date: Tue, 21 Sep 2004 01:37:26 +0000
Subject: Re: Extrange behavior with Header('Location')
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-197377@lists.php.net to get a copy of this message
Jordi Canals wrote:
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&amp;id=3 Note the &amp; in the URL Well, with this code, the url works perfect and the &amp; is going as expected redirecting to /myaccount/?opt=sys&id=3 echo '<a href="'. $url .'">Test URL</a>';
This is correct, you should use entities in html atributes
But when triying header("Location: $url");
But not in headers
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.
Another method in your class that will return unencoded urls.

« previous php.general (#197377) next »