Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
| Search | Today's Posts | Mark Forums Read
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 4th, 2006, 12:32 PM
Registered User
 
Join Date: Jan 2006
Location: , , Italy.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default .php files vs .html files

Hello guys,

I have experimented a difficulty in configuring my Apache server with PHP. I followed a lot of suggestions and I had always the same problems. I placed my index.html file in the root directory of my test web site and I wrote the following code:


<html>
  <body>
    <?php echo 'This is going to be parsed.'; ?>
  </body>
</html>


but I noted that the code was not executed. So I placed index.php file in the root directory with the following content:


<? echo 'This is going to be parsed.'; ?>


and I saw this works! Could anybody explain to me the difference in writing .html file containing php code and .php files? Why does the code contained in .html file be not executed? I understand this is a problem of configuration... but I have no solutions.

Many thanks in advance.

Piergiorgio

 
Old January 4th, 2006, 03:13 PM
Friend of Wrox
 
Join Date: Mar 2004
Location: Bhopal, MP, India.
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul
Default

Quote:
quote:.html file be not executed
It shouldn't be; it is a static HTML file. How Apache knows it contain PHP code!

If you wanna parse HTML as PHP, you may add below line to '.htaccess' file directory wise:
AddType application/x-httpd-php .html

This can be also done in Apache, so it is asked to parse HTML as PHP.

Easy?

`~@#\^%&*/\.<.\/-|+|_!:;..=?>
Students' finances
 
Old January 5th, 2006, 04:15 AM
Registered User
 
Join Date: Jan 2006
Location: , , Italy.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:
AddType application/x-httpd-php .html
Many thanks for the above suggestion... it's very easy. I did not imagine that the problem was so simple to be solved! Now my .html files work well!!!

Bye

Piergiorgio





Similar Threads
Thread Thread Starter Forum Replies Last Post
jsp files and html files jamara ASP.NET 2.0 Basics 1 November 20th, 2006 07:03 AM
Generating multiple HTML files dunpeal ASP.NET 1.0 and 1.1 Professional 6 August 24th, 2006 07:16 AM
Two HTML files Question bonekrusher XSLT 2 August 10th, 2006 02:04 PM
Can you preload child html files to 1parent html? bekim Javascript How-To 4 January 22nd, 2005 04:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.