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

Popular Categories





Can I use PHP extension in a html page?

+1 vote
72 views
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 4,750 views
+2 votes
1 answer 133 views
+1 vote
1 answer 729 views
+4 votes
1 answer 613 views
+6 votes
3 answers 6,802 views
+5 votes
1 answer 71 views

Not a Member yet?

Ask to Folks Login

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