|
Subject:
|
.php files vs .html files
|
|
Posted By:
|
pbuongiovanni
|
Post Date:
|
1/4/2006 11:32:24 AM
|
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
|
|
Reply By:
|
anshul
|
Reply Date:
|
1/4/2006 2:13:42 PM
|
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
|
|
Reply By:
|
pbuongiovanni
|
Reply Date:
|
1/5/2006 3:15:40 AM
|
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
|