Re: Re: header

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tedd wrote:
At 3:16 PM +0100 9/16/08, Nathan Rixham wrote:
Alain R. wrote:
Hi,

how in PHP can i create the similar header as following ?
<head>
<base href="www.mywebsite.com">
</head>

thx.

A.

just incase everybody else went down a complete tangent on this one

<head>
<base href="<?php echo $_SERVER['HTTP_HOST']; ?>">
</head>

it's not nice, elegant, the *proper* way to do things but it'll do the job if I understand you correctly


I don't see anything wrong with it. It looks nice, elegant and proper to me.

Cheers,

tedd

thanks tedd, to be full proof though there's a lot lacking; for example http/1.0 browsers don't pass through HTTP_HOST seeing as it's only in http/1.1; also even on http/1.1 it's sometimes spoofed; further there's the whole HTTPS_HOST to concider; there's only one full proof method and thats to simple hard code or define it:

define('PUBLIC_BASE_HREF' , 'http://php.net/')
<head>
<?php echo PUBLIC_BASE_HREF; ?>
</head>

or the "will probably work for all http/1.1 https calls" multi-site version:

<?php
define('ACCESS_PROTOCOL', isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] ? ( $_SERVER['HTTPS'] && strtolower($_SERVER['HTTPS']) != 'off' ? 'https' : 'http' ) : 'http' . '://');
if( isset($_SERVER['HTTP_HOST']) && $_SERVER['HTTP_HOST'] ) {
define('PUBLIC_BASE_HREF', ACCESS_PROTOCOL . strtolower($_SERVER['HTTP_HOST']) . '/');
} else {
	define('PUBLIC_BASE_HREF', FALSE);
}
function html_base_href() {
return PUBLIC_BASE_HREF ? '<base href="' . PUBLIC_BASE_HREF . '">' . PHP_EOL : '';
}

?>
<head>
<?php echo html_base_href(); ?>
</head>

and I really don't have the time to go into templating;

somebody should really bring out a "class environment" or such like with all of this in it..

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux