php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44479 Error while using a constant in header()-function
Submitted: 2008-03-19 12:53 UTC Modified: 2008-03-19 13:23 UTC
From: ingo dot kasch at gmx dot de Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2.5 OS: Windows XP Professional
Private report: No CVE-ID: None
 [2008-03-19 12:53 UTC] ingo dot kasch at gmx dot de
Description:
------------
Hi,

while using a constant for defining a hyperlink-target (http-adress) and using this constand to do a header();redirect there comes an object not found-error (404) in the browser.

The reason is that php could not interpret the value of the constant and using the constants name for the header();-function.

Reproduce code:
---------------
Not working code:
<?php
	define('HOME', 'http://www.google.de');
	header("Location: HOME");
?>


WORKING CODE:
<?php
	define('HOME', 'http://www.google.de');
        $home_var = HOME;

	header("Location: $home_var");
?>

Expected result:
----------------
I expected a redirct to the defined value of the constant, in this example 'http://www.google.de'.

Actual result:
--------------
The browser is redircting to /HOME using the actual url of the page and just adding /HOME (which is the name of the constant, not the value) in the end of the adress bar.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-03-19 13:23 UTC] scottmac@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

constants aren't parsed in strings.

header("Location: " . HOME);

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 21 13:00:02 2025 UTC