Re: Re: header

From: Date: Tue, 16 Sep 2008 18:45:07 +0000
Subject: Re: Re: header
References: 1 2 3 4 5 6 7  Groups: php.general 
Request: Send a blank email to php-general+get-280300@lists.php.net to get a copy of this message
Robert Cummings wrote: > On Tue, 2008-09-16 at 18:13 +0100, Nathan Rixham wrote: >> I also meant: >> define('PUBLIC_BASE_HREF' , >> 'http://php.net/') >> <head> >> <base href="<?php echo PUBLIC_BASE_HREF; ?>" /> >> </head> >> >> and further thinking there has to be an easier / cleaner way of getting >> "http://" / >> "https://" in php.. > > What's wrong with $_SERVER['HTTPS'] ? > > Cheers, > Rob. my way <?php function get_http_protocol() { $proto = 'http'; if ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ) { $proto .= 's'; } return $proto . '://'; # Adding the :// is optionial } echo get_http_protocol(); ?> That is about as simple as you can get. -- Jim Lucas "Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them." Twelfth Night, Act II, Scene V by William Shakespeare

« previous php.general (#280300) next »