添加php代码时未包含jQuery源文件 - php

该代码运行良好,但是在我添加了以下php代码之后,一切都掉了。我添加了如下所示的php代码后,它为jquery-1.11.3.js指出“无法加载资源”。
我在这里完全迷路了。不知道这是怎么了。

<?php
    $currentMonthInInteger = date("n");
    $currentYear = date("Y");

    $timestamp = mktime(0, 0, 0, $currentMonthInInteger, 1, $currentYear);

    $totalday = date("t", $timestamp);
    $thismonth = getdate($timestamp);
    $firstday = $thismonth['wday'] - 1;

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" 
"http://www.w3.org/TR/REC-html40/loose.dtd">
    <html>
        <head>
            <meta charset="utf-8" />
            <title>CALENDAR</title>
            <script type="text/javascript" src="include/jquery-1.11.3.js"></script>

            <style>

                table{
                    position: relative;
                    border: 1px solid black;
                    height: 400px;
                    width: 700px;
                    table-layout: fixed;
                    border-collapse: collapse;
                }

                td{
                    display: inline;
                    border: 1px solid black;
                    position: static;
                    text-align: center;
                    font-size: 1.5em;
                    padding: 12px 20px;
                    height: 57px;
                }

                #head{
                    height: 57px;
                }
                caption{
                    font-size: 2.2em;
                }

            </style>    
        </head>


    <body>

        <div id="main" align = "center">
            <table id="ref">
            <!--<tr>-->
                <caption id="month">JULY</caption>
            <!--</tr>-->

                    <tr id="head">
                        <th>MON</th>
                        <th>TUE</th>
                        <th>WED</th>
                        <th>THU</th>
                        <th>FRI</th>
                        <th>SAT</th>
                        <th>SUN</th>
                    </tr>

                    <tr>
                        <td><span id = 0>00</span></td>
                        <td><span id = 1>01</span></td>
                        <td><span id = 2>02</span></td>
                        <td><span id = 3>03</span></td>
                        <td><span id = 4>04</span></td>
                        <td><span id = 5>05</span></td>
                        <td><span id = 6>06</span></td>
                    </tr>

                    <tr>
                        <td><span id = 7>07</span></td>
                        <td><span id = 8>08</span></td>
                        <td><span id = 9>09</span></td>
                        <td><span id = 10>10</span></td>
                        <td><span id = 11>11</span></td>
                        <td><span id = 12>12</span></td>
                        <td><span id = 13>13</span></td>
                    </tr>

                    <tr>
                        <td><span id = 14>14</span></td>
                        <td><span id = 15>15</span></td>
                        <td><span id = 16>16</span></td>
                        <td><span id = 17>17</span></td>
                        <td><span id = 18>18</span></td>
                        <td><span id = 19>19</span></td>
                        <td><span id = 20>20</span></td>
                    </tr>

                    <tr>
                        <td><span id = 21>21</span></td>
                        <td><span id = 22>22</span></td>
                        <td><span id = 23>23</span></td>
                        <td><span id = 24>24</span></td>
                        <td><span id = 25>25</span></td>
                        <td><span id = 26>26</span></td>
                        <td><span id = 27>27</span></td>
                    </tr>

                    <tr>
                        <td><span id = 28>28</span></td>
                        <td><span id = 29>29</span></td>
                        <td><span id = 30>30</span></td>
                        <td><span id = 31>31</span></td>
                        <td><span id = 32>32</span></td>
                        <td><span id = 33>33</span></td>
                        <td><span id = 34>34</span></td>

                    <tr>
                        <td><span id = 35>35</span></td>
                        <td><span id = 36>36</span></td>
                    </tr>

                </table>


                        <br><br>
                        <button onclick = previousMonth()>Previous Month</button>
                        &nbsp;&nbsp;&nbsp;
                        <button onclick = nextMonth()>Next Month</button>

            </div>


        </body>
    </html>
        <script>...
</script>

参考方案

首先,检查文件夹include是否与您的php文件位于同一目录中,例如:

\include\jquery-1.11.3.js
\index.php

Javascript标记src路径相对于引用它的html / php文件的位置,或者可以相对于php站点的根目录,具体取决于您的配置。因此,如果您的文件结构如上,但仍未加载,则尝试将包含include的目录包括在src路径中,例如尝试不同的方法:

<script src="include/jquery-1.11.3.js"></script>
<script src="/include/jquery-1.11.3.js"></script>
<script src="../include/jquery-1.11.3.js"></script>
<script src="[DIRECTORY]/include/jquery-1.11.3.js"></script>

另外,您可以使用jQuery CDN加载jQuery:

<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>

有关其他jQuery版本和相关项目,请参见:jQuery CDN

php Singleton类实例将在多个会话中保留吗? - php

举一个简单的例子,如果我想计算一个不使用磁盘存储的脚本的命中次数,我可以使用静态类成员来执行此操作吗?用户1:<?php $test = Example::singleton(); $test->visits++; ?> 用户2:<?php $test = Example::singleton(); $test->visits+…

如何使用BeautifulSoup在<tr>中捕获特定的<td> - python

尝试从nyc Wiki页面中的高中列表中获取所有高中名称。我已经写了足够多的脚本,可以让我获取包含在高中,学业和入学条件列表的表的<tr>标记中的所有信息-但是我如何才能缩小到我认为的范围内在td[0]内休息(会弹出KeyError)-只是学校的名称?到目前为止我写的代码:from bs4 import BeautifulSoup from ur…

通过>和<运算符比较日期 - php

在我的所有php代码中,我都在UTC中存储日期和时间,但是我也在使用mysql存储日期时间(也在utc中)。大于和小于运算符会导致日期比较失败吗? $curdate=date('Y-m-d H:i:s'); if($start_datetime>$curdate) 参考方案 不。他们没有办法失败。为此,特意制作了MySQL日期格式。…

使用jquery计算<id>中的总图像 - php

我有一个div,里面有一些图像,例如<img src= etc我想计算该div中的图像总数。我也想使用PHP将这些图像ID保存到mysql中...谢谢 参考方案 要计算它们,您可以执行以下操作:alert($('#myDiv img').length); 要将所有id捕获到数组中,可以执行以下操作:var ids = []; $(&…

为什么我不能使用<br>来填充textarea,所以我使用ajax - php

这是我使用的ajax im,$.ajax({ type: "POST", url: "../../Ajax/<?php echo $exercise_num ?>", data: "user_input=" + user_input, success: function(resp){ /…