Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

$_SERVER['REQUEST_URI'] returns undefined index error

Posted on 2008-10-13
2
1,072 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

861 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