PHP in HTML page, Super Quick Advice

前端 未结 3 1569
日久生厌
日久生厌 2021-01-28 06:57

I\'m no genius when it comes to coding, but I google enough to figure things out... I have a quick question.

  1. I have a page \"index.html\", \"events.html\" etc...
3条回答
  •  情深已故
    2021-01-28 07:22

    If you want to execute php code in .html file extension than u need to do some htaccess changes. Since file-extension plays a major role, it only tells the browser how to handle or parse a particular page.

    You can create a .htaccess file at the root folder of your website and in the .htaccess file add this line:

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

    If you only plan on including the PHP on one page, it is better to setup this way:

    
    AddType application/x-httpd-php .html
    
    

    This code will only make the PHP executable on the yourpage.html file, and not on all of your html pages.

    If you are ok with changing your file extension to .php than your work will be quite easy.you can simply include a php code between html code.like this

    see here

    detail

提交回复
热议问题