Re: PHP4 vs PHP5
| From: | Drew Butler | Date: | Sat, 07 Jan 2006 19:31:16 +0000 |
| Subject: | Re: PHP4 vs PHP5 | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-228293@lists.php.net to get a copy of this message | ||
A simplified version of this would be:
$glb_http_ref = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER']
: "";
or just:
$glb_http_ref = @$_SERVER['HTTP_REFERER'];
The latter will suppress the error message and return a null (or a blank as
far as PHP is concerned. Not the cleanest route and I prefer the first
method, but just thought I would get some options out there. :)
On 1/7/06, Gerry Danen <gdanen@gmail.com> wrote:
>
> On 1/7/06, Kevin Waterson <kevin@oceania.net> wrote:
> >
> > This one time, at band camp, Gerry Danen <gdanen@gmail.com> wrote:
> >
> > > I'm wondering if $_SERVER['HTTP_REFERER'] is no longer supported, or
> > perhaps
> > > has a new name?
> >
> > still there, same name.
> >
> > print_r($_SERVER);
>
>
> Ah, yes. It's there when the page is actually referred from somewhere,
> otherwise it's not.
>
> Thanks, Kevin.
>
> Now my simple assignment becomes a conditional assignment to avoid clutter
> in the error log:
>
> if ( isset($_SERVER['HTTP_REFERER']) )
> $glb_http_ref = $_SERVER['HTTP_REFERER'];
> else
> $glb_http_ref = "";
>
> instead of
>
> $glb_http_ref = $_SERVER['HTTP_REFERER'];
>
> Learning as I go... :)
>
> Gerry
>
>