Forum Moderators: coopster

Message Too Old, No Replies

preventing undefined index notices

         

topr8

2:41 pm on Jan 6, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



i'm using this snippet of code:

if ($_SERVER["HTTPS"] == "on"){ .... stuff here

and i'm getting a php notice.

eg. Notice: Undefined index: HTTPS in /var/....../filename.php on line 55

how would i avoid this?

i'm getting a similar problem with
if ($_SERVER["HTTP_REFERER"]){

i'm gettign a similar notice,
eg: Undefined index: HTTP_REFERER in ...

any ideas? i know a notice isn't critical but i'd like to keep it tidy.

Psychopsia

3:02 pm on Jan 6, 2010 (gmt 0)

10+ Year Member



Hello! The following can work too:

$_SERVER["SERVER_PORT"] === 443

I use this and work fine.

dreamcatcher

4:21 pm on Jan 6, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Use isset [php.net].

if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on")...

if (isset($_SERVER["HTTP_REFERER"])) {
code here..
}

dc

topr8

5:04 pm on Jan 6, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



great, using isset worked, thank you