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

Your name:

Reply:


Posted by Anonymous on 05/29/05 11:19

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!

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация