Hey there! any question in your mind? Ask It Now!.

Popular Categories

Can I use PHP extension in a html page?

+1 vote
asked in Programming by ramesh (630 points)
retagged by Bhartesh
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
answered by vicky (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
answered by amit_pammu Expert (5,030 points)
reshown by amit_pammu
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.

Related Questions

+1 vote
2 answers 6,139 views
0 votes
1 answer 192 views
+2 votes
1 answer 165 views
+1 vote
1 answer 861 views
+4 votes
1 answer 671 views
+6 votes
3 answers 7,189 views
+5 votes
1 answer 274 views
+6 votes
1 answer 286 views
+3 votes
3 answers 2,822 views

Not a Member yet?

Ask to Folks Login

My Account
371 Folks are online
0 members and 371 guest online
Your feedback is highly appreciated