Solved

$_SERVER['REQUEST_URI'] returns undefined index error

Posted on 2008-10-13
2
1,067 Views
Last Modified: 2013-12-13
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

0
Comment
Question by:shankar_nr
2 Comments
 
LVL 3

Accepted Solution

by:
wktang83 earned 125 total points
ID: 22708011
Are you running the php code on IIS?

Read here for workarounds: http://orangehrm.com/forum/viewtopic.php?t=124
0
 
LVL 2

Author Closing Comment

by:shankar_nr
ID: 31505755
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now