$_SERVER['REQUEST_URI'] returns undefined index error

I had a local site I am developing work before my PC crashed. I have a new PC and have setup php 5.2.6 and now my function which used to work before does not work It returns the error:

PHP Notice: Undefined index: REQUEST_URI in C:\Nilesh\CenvetSite\custom\functions.php on line 6

Does anyone have any ideas whats going wrong?
function selfURL() {
		$s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : "";
		$protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s;
		$port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]);
		return $protocol."://".$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI']; 
	}

Open in new window

LVL 2
shankar_nrAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
wktang83Connect With a Mentor Commented:
Are you running the php code on IIS?

Read here for workarounds: http://orangehrm.com/forum/viewtopic.php?t=124
0
 
shankar_nrAuthor Commented:
yep thats it. what I do not understand however is why it used to work before with php and IIS and now it doesnt.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.