douqiao8032 2013-01-31 21:18
浏览 28
已采纳

PHP块未在html中解析

I am writing the following html code:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 

<script type="text/javascript">
    function detectBrowser(){
        if(navigator.appName === "Microsoft Internet Explorer"){
            window.open("redirect.html", "_parent");
        }
    }
</script>
</head>

<body onload="detectBrowser()">
<div class="mainBody">  
<?php
    echo "test";
?>
</div>
</body>
</html>

But the php block doesn't display test for me. It looks like it is not parsed and I can see the php code in the webpage's source. Any one can tell the problem?
Thank you

  • 写回答

2条回答 默认 最新

  • drsrq26482 2013-01-31 21:23
    关注

    You can enable parsing of PHP in files with .html extensions in your httpd.conf file.

    Look for a line like this and make sure .html is an option.

     AddType application/x-httpd-php .php .php3 .phtml .html 
    

    You could probably add it to an .htaccess file in the docroot of you site as well, but I've not tried this personally.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示