+ 6

[Solved] IS IT POSSIBLE TO USE PHP CODE IN .HTML FILE?

If I use html in .php file it will work just fine but if I use php code in .html file it's not working. We can use include('file.php') command but for that too we have to make .php file to use that because it's a php command, so basically my question is can we use .php code in .html?

28th May 2018, 8:25 PM
Bhagyesh✨
Bhagyesh✨ - avatar
3 Answers
+ 1
it is possible if you configure the server to process php in .HTML files rather than serve them as static files.
2nd Jun 2018, 9:16 AM
J.M. Muriithi
J.M. Muriithi - avatar
+ 3
you can send ajax requests to php scripts from your html page and use the server response to dynamycally manipulate the dom
29th May 2018, 4:43 PM
seamiki
seamiki - avatar
+ 2
You cannot use php in .html files. The .html files are most likely to be generated by php templates system, which is implemented via programmers or they are already built in framework if you are using one.
28th May 2018, 11:50 PM
Jakub Stasiak
Jakub Stasiak - avatar