« Zend Core for Oracle 2.0 Released | Main | PHP RPMs for Oracle »

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 (7)

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.

Alison Holloway:

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.

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.

Les Quinn:

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...

Alison Holloway:

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

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

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

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About This Entry

This page contains a single entry from the blog posted on May 24, 2007 5:28 PM.

The previous post in this blog was Zend Core for Oracle 2.0 Released.

The next post in this blog is PHP RPMs for Oracle.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type and Oracle