I am running code on different versions of PHP, specifically 4.0.6 and
4.1.2. For some reason, you have to use $HTTP_SERVER_VARS["HTTP_HOST"]) on
4.0.6 and $_SERVER["HTTP_HOST"] on 4.1.2. I'm not sure who thought that
breaking backward compatibility was a good idea, but let's ignore that for
the moment. In this situation, the obvious thing to do here would be to
make a common function to return the hostname. But, this does not work as
illustrated below:
----------------- this is the main PHP script
<?php
//main.php
include ("crap.php");
function thisalsonowork()
{
print "Third one: (".isset($HTTP_SERVER_VARS["HTTP_HOST"]).")";
}
thisnowork();
print "Second one: (".isset($HTTP_SERVER_VARS["HTTP_HOST"]).")";
thisalsonowork();
?>
--------------- this is the include/require script
<?php
//crap.php
function thisnowork()
{
print "First one: (".isset($HTTP_SERVER_VARS["HTTP_HOST"]).")";
}
?>
----------- Here is the output
First one: ()Second one: (1)Third one: ()
Besides the fact that the different versions of PHP provide different
environment variables for determining the host, the isset() on the env
variable works differently inside a function. What is going on here?
Am I just missing something obvious?
Thanks,
-- Brian
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php