简体   繁体   English

php代码在.html文件中不起作用

[英]php code is not working inside .html file

I have added php code in html file and run this file as .html extension. 我已经在html文件中添加了php代码,并以.html扩展名运行此文件。 For this technique i have added below code in .htaccess file. 对于这种技术,我在.htaccess文件中添加了以下代码。

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

This whole folder is sub directory of wordpress project folder.When i am run this file in server, pop-up comes and my code file is opens in popup and it will give option to download. 整个文件夹是wordpress项目文件夹的子目录。当我在服务器上运行此文件时,弹出窗口出现,我的代码文件在弹出窗口中打开,它将提供下载选项。 where i can see the whole code. 在这里我可以看到整个代码。 What should i do to prevent to pop up box for download and run php code in html file and open as .html extension. 我应该怎么做才能防止弹出框下载并在html文件中运行php代码并以.html扩展名打开。

我在执行文件时显示它。

Can anyone help me what should i do? 谁能帮我该怎么办?

In order to use php in .html files, you must associate them with your PHP processor in your HTTP server's config file. 为了在.html文件中使用php,必须在HTTP服务器的配置文件中将它们与PHP处理器关联。 In Apache, that looks like this: 在Apache中,如下所示:

AddHandler application/x-httpd-php .html

Your php block of codes must be inside the tag 您的php代码块必须位于标记内

 <?php // Your php code might not work here ?> <!DOCTYPE html> <html> <?php // Your php code will work here ?> <head> <title>Title</title> </head> <body> <?php // Your php code will also work here ?> </body> </html> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM