在HTML中包含php脚本 [英] include php script inside HTML

查看:71
本文介绍了在HTML中包含php脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新手,从未使用过PHP。我想从Linux上的HTML文件执行PHP脚本。我需要做什么?



这是我的HTML文件的内容:

 <!DOCTYPE HTML PUBLIC -  // W3C // DTD HTML 4.01 // EN
http://www.w3.org/TR/html4/strict.dtd\">
< HTML>
< HEAD>
< TITLE>测试天气数据< / TITLE>
< / HEAD>
< BODY>
< div id =weather>
< p>天气信息
<?php include/home/tahoang/Desktop/weatherData.php; ?>
< / div>
< / BODY>
< / HTML>


解决方案

您会收到什么输出?它只是显示PHP代码?



我假设是这种情况。



对于测试,更改将文件扩展名为 .php 并再次运行。它现在有效吗?如果是这样,你需要将PHP与 .html 和<$ c $相关联c> .htm 您服务器上的文件。



编辑



这是你要添加到你的Apache配置的行:

  AddType application / x-httpd-php。 html 


I am a newbie and have never used PHP before. I want to execute PHP script from an HTML file on Linux. What do I need to do?

This is the content of my HTML file:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
<HTML>
   <HEAD>
      <TITLE>Testing Weather Data</TITLE>
   </HEAD>
   <BODY>
      <div id="weather">
         <p>Weather Information
         <?php include "/home/tahoang/Desktop/weatherData.php"; ?>
      </div>
   </BODY>
</HTML>

解决方案

What output do you receive? Does it just show the PHP code?

I assume that's the case.

For a test, change the extension on the file to .php and run it again. Does it work now?

If so, you will need to associate PHP with .html and .htm files on your server.

EDIT

This is the line you want to add to your Apache config:

AddType application/x-httpd-php .html

这篇关于在HTML中包含php脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆