My Test PHP File Cannot Display in the Browser Window

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

To tell you the truth, basically I am nobody insofar as scripting PHP
is concerned. However, I fell in love with the language after reading
great things about what the language  can do, and so I downloaded and
installed PHP5 and set up to work with Apache 2 on my PC according to
the instructions set forth at .

I embedded a test php script inside an html file which is something
like this:

      <head> <title>Tesing PHP Scripting </title> </head>
          Testing PHP Scripting:<br>

and saved it as
in the
      Apache Group\Apache2\htdocs

When I tried to run the file in IE6, instead of outputting the result
in the browser screen, the test.php file -text file(the sourse
code)opens up in the text editor that i used to create it. I just don't
know what is going on, and I don't know where to go from here in my
quest to learn PHP.

Any help from you good people?


Re: My Test PHP File Cannot Display in the Browser Window

Quoted text here. Click to load it

You can't open the file directly - you have to go through the server.

Assuming your server (that Apache and PHP are on) is the same machine as the
one you're using to view, you need to open http://localhost/<PHP-path>

If your PHP test script is in the wwwroot directory, that would be

with "testfile.php" being whatever file name you used.

Tony Garcia

Re: My Test PHP File Cannot Display in the Browser Window

Thanks so much, Tony.

I tried a) http://localhost/test.php
b) http://ipAddress/test.php

and both worked. Now I'll jump into the php wagon and try riding.


Re: My Test PHP File Cannot Display in the Browser Window

Jofio wrote:
Quoted text here. Click to load it

There are several errors here:

1) You better don't use short tags. PHP can be configured not to accept
them and if you don't know how your PHP (or the PHP version on the
server the script is supposed to run in the end) is configured you
should only use "<?php" instead of "<?".

2) The function phpinfo() returns a whole webpage with info about the
installed PHP version and its configuration. Don't embrace it with HTML
tags. Your testscript should therefore look like this:


3) You don't run php files in your browser. The server runs them and
delivers the result to your browser. You will have to access the file
through the server using:

4) If that does not work make sure that ...

 4a) ... the Apache server is running.
 4b) ... Apache is really configured to deliver the pages from the
htdocs directory. (Should be by default, but perhaps you changed that
and forgot about it.)
 4c) ... Apache is really configured to use PHP.

If 4a) fails you will see an IE error message that it can't access the
page. If 4b) fails IE will show you an error message it received from
Apache, that it can't find the requested file. In case of 4c) failing IE
will show you what it received from Apache: The PHP sourcecode as text.

That should get you going for the start.


Re: My Test PHP File Cannot Display in the Browser Window

Thanks so much.

Infact http://myIPaddress/test.php and http://localhost/test.php both


Site Timeline