By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,409 Members | 1,604 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,409 IT Pros & Developers. It's quick & easy.

My Test PHP File Cannot Display in the Browser Window

P: n/a
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 http://www.php.net.

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

<html>
<head> <title>Tesing PHP Scripting </title> </head>
<body>
Testing PHP Scripting:<br>
<?
phpinfo();
?>
</body>
</html>

and saved it as
test.php
in the
Apache Group\Apache2\htdocs
directory.

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?
Jofio

Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Jofio wrote:

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 http://www.php.net.

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

<html>
<head> <title>Tesing PHP Scripting </title> </head>
<body>
Testing PHP Scripting:<br>
<?
phpinfo();
?>
</body>
</html>

and saved it as
test.php
in the
Apache Group\Apache2\htdocs
directory.

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?


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:

<?php
phpinfo();
?>

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:

http://127.0.0.1/test.php

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.

Bye!
Jul 17 '05 #2

P: n/a
"Jofio" <j9******@yahoo.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...

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?


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
http://localhost/testfile.php

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

--
Tony Garcia
www.dslextreme.com/~tony23/
Jul 17 '05 #3

P: n/a
Thanks so much, Tony.

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

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

jofio

Jul 17 '05 #4

P: n/a
Thanks so much.

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

jofio

Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.