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 如何在炒股软件中,爬到我想看的日k线
  • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起