How do I add PHP code/file to HTML(.html) files?

后端 未结 12 2089
栀梦
栀梦 2020-11-21 22:05

I can\'t use PHP in my HTML pages. For example, index.html. I\'ve tried using both:

 

and



        
12条回答
  •  南笙
    南笙 (楼主)
    2020-11-21 22:35

    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 your root web directory and add this line to it:

    AddType application/x-httpd-php .htm .html
    

    This will tell Apache to process files with a .htm or .html file extension as PHP files.

提交回复
热议问题