+1 vote
in Programming by (630 points)
retagged by
I have a html file and want to add some PHP code on that,I have used htm format also but nothing is working.can you tell me what I am missing?
Or should I change preferences in php.ini ? Please help me on this!

2 Answers

+2 votes
by (390 points)
You can't run PHP in .html files because the server does not recognize that as a valid PHP extension unless you tell it to. To do this you need to create a .htaccess file in root web directory 
write this code there 
AddType application/x-httpd-php .htm .html
This wil tell the server to process .html or .htm files with php extension.
0 votes
by Expert (5.1k points)
reshown by
yes you can save your file with php extension .php , but you need a server to run that file because php is a server side language ..so you can run it on "localhost".

so after adding the php code and save it with the .php just put your file to localhost server and run through it.

Not a Member yet?

Ask to Folks Login

My Account

Your feedback is highly appreciated