dquv73115 2011-10-27 20:40
浏览 34

为什么PHP不处理我的PHP脚本?

I am trying to include a calendar into my website that I am designing. Not really knowing how to create an event calendar, I chanced upon this calendar that was created using javascript. However, I can't seem to get it working.

Here is the code, in a file with an extension of .html:

<head>  
<script type="text/javascript" src="date/calendar.js"></script>
</head>

<body>
Date
<form action="somewhere.php" method="post">
    <?php
    //get class into the page
    require_once('date/classes/tc_calendar.php');

    //instantiate class and set properties
    $myCalendar = new tc_calendar("date1");
    $myCalendar->setDate(date("d"), date("m"), date("Y"));
    $myCalendar->setSpecificDate(array("2011-04-01", "2011-04-14", "2011-04-25"), 0, "month");

    //output the calendar
    $myCalendar->writeScript();
    ?>
</form>
</body>

It appears that the PHP in the webpage isn't being processed. What's visible in the browser is:

Date
setDate(date("d"), date("m"), date("Y")); $myCalendar->setSpecificDate(array("2011-04-01", "2011-04-14", "2011-04-25"), 0, "month"); //output the calendar $myCalendar->writeScript(); ?>

I do not understand what is wrong here.

I'd appreciate any help.

Cheers,

Josh

  • 写回答

1条回答 默认 最新

  • duandiaoqian5795 2011-10-27 20:47
    关注

    Web servers generally won't parse php in .html files. Change the file extension from .html to .php

    You could force your server to parse PHP in html files as well as PHP files (with something like AddHandler php5-script .html for apache), but that's generally bad practice.

    评论

报告相同问题?

悬赏问题

  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决