phpinfo() Not Displayed Correctly

Since I've started blogging about little idiosyncracies I've been experiencing in PHP, I've been getting feedback that you want more. Okay. I'll start adding little tid-bits that might help out someone out there. So here's one I found (again) today.

While testing the bug fix I mentioned in an blog entry last week, I found that trying to load the phpinfo() script caused my browser to try loading the file as an application. That is, it tried to download the file, rather than execute the script. This happened in Firefox and IE. For those not familiar with phpinfo(), it's a function that displays the setup of PHP, including loaded extensions, environment variables, PHP variables, and so on. Here's what you would use:

phpinfo.php

<?php
phpinfo();
?>
I'm getting side-tracked. You'll likely all know how to use this function, but that was for newbies.

So, if you try to load this script using localhost in the URL, your browser will not know how to deal with it, nor will PHP, so it strangely asks you what to do with it. This doesn't happen to my other PHP scripts. So, don't use:

http://localhost/phpinfo.php

Use

http://127.0.0.1/phpinfo.php

If this is far too simple a blog, let me know. I'll get back into the more unusual stuff.

Comments:

Strange, I've never had the problem. In fact, accessing that exact url through localhost is working fine for me right now. Perhaps there is something in your webserver configuration at work.

Posted by Robert Deaton on May 24, 2007 at 03:03 PM DDUT #

Perhaps it's a DHCP thing? I don't have a static IP address. I know I've seen it happen before, but can't always reproduce it. I generally use 1.2.0.0.1 instead of localhost anyway, so I haven't quite worked out where the real problem is coming from. Thanks for your comment. It's helped me to think about it a little more.

Posted by Alison Holloway on May 24, 2007 at 04:17 PM DDUT #

If people are having problems with localhost address instead of ip when running their server on their local box, might want to check your hosts file. In windows, it is probably under C:\Windows\System32\Drivers\etc\ If you open up the hosts file in notepad or whatnot, you should be able to see where hostnames are mapped to ips on your machine. For example: 127.0.0.1 localhost should at least be there. If not, that'd be why localhost doesn't point to 127.0.0.1 and you'd need to type it in explicitly. If you set up any virtual hosts on your local box, you'll also need to put their aliases and ips here as well. Multiple hostnames can be tied to a single ip, if necessary, so long as the virtual host directories are pointed to specific locations in the apache conf. Hope that helps.

Posted by Daniel C. Henning on June 01, 2007 at 09:41 AM DDUT #

I've never had this problem either in the 4 years of PHP development, so I can only think that it's a particular configuration of your own system. > If this is far too simple a blog, let me know. Yes it is; What I want to read is how to scale PHP applications and how Oracle can help me do so, both in regards to Oracle products and services, as well as Open Source material. That is one issue I face today. Leave the newbies to the amatuer sites please...

Posted by Les Quinn on June 25, 2007 at 08:44 AM DDUT #

Thanks Les. That's a good topic suggestion. Noted.

Posted by Alison Holloway on June 25, 2007 at 01:33 PM DDUT #

Check for a mapping for localhost in /etc/hosts (or %WinRoot%\System32\drivers\etc for Windows) on the machine on which you browse, e.g.: 127.0.0.1 localhost localhost.mydomain

Posted by Adrian Penisoara on December 06, 2007 at 07:50 PM DDUT #

Wow, cool man, big thanks! http://pvzntdzzzuf.com

Posted by ehbpfomuyc on May 14, 2008 at 08:59 AM DDUT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

A blog on Oracle VM, PHP and any other projects I work on.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today