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

Popular Categories





Can I use PHP extension in a html page?

+1 vote
78 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 5,234 views
0 votes
1 answer 132 views
+2 votes
1 answer 139 views
+1 vote
1 answer 739 views
+4 votes
1 answer 615 views
+6 votes
3 answers 6,836 views
+5 votes
1 answer 74 views
+6 votes
1 answer 238 views
+3 votes
3 answers 2,448 views

Not a Member yet?

Ask to Folks Login

My Account
637 Folks are online
55 members and 582 guest online
Your feedback is highly appreciated