2013-05-14 94 views
1

我想通过David Walsh修改日历脚本。在David的脚本中显示每月的日历,第一周它在月份开始之前显示空白,但评论者说您可以使用以下代码显示上个月的日期,即28 20 30,具体取决于月份的第一天何时落入。php mktime函数产生奇怪的符号

我不会重复链接到脚本的所有代码,但主要的是替换代码显示一个我从未见过的符号.., 30 。 (我已经从他的来源复制了这些符号,它们是正方形,表示在PD之上的FF)。这是代码。注意$ x,$ running_day和$ daysInThisWeek只是数字。 $日历得到回应结束。

//following prints out empty table cells 

for($x = 0; $x < $running_day; $x++): 
     $calendar.= '<td class="calendar-day-np">&nbsp;</td>'; 
     $days_in_this_week++; 
    endfor; 
echo $calendar; 

//但是下面,呼应,打印出奇怪的符号:

$daysInLastMonth = date(‘t’,mktime(0,0,0,$month-1,1,$year)); 

然后,当你遍历如上你得到一大堆的奇怪符号。

for($x = 0; $x < $running_day; $x++): //this line is same as above 
$calendar.= ' . (($daysInLastMonth – ($runningDay – 1)) + $x). '; 
$daysInThisWeek++; 
endfor; 
echo $calendar; 

有谁知道可能会发生什么,奇怪的符号是什么意思,以及如何得到这个显示正常。

感谢您的任何建议!

回答

2

打开所有错误,你会看到你有错误的引号。错误会像

注意:使用未定义的常量 'T' - 假定 '' T ''

此行

$daysInLastMonth = date(‘t’,mktime(0,0,0,$month-1,1,$year)); 

必须

$daysInLastMonth = date('t',mktime(0,0,0,$month-1,1,$year)); 
+0

哇。谢谢。我不知道要花多长时间才能弄清楚。更改了标点符号并修复了它。谢谢。当它让我时,它会标记正确。 – user1904273 2013-05-14 00:17:26

+0

@ user1904273,使用error_reporting(-1)并读取日志 – sectus 2013-05-14 00:28:33

2

有一个错误:

$daysInLastMonth = date(‘t’,mktime(0,0,0,$month-1,1,$year));

它应该是:

$daysInLastMonth = date('t',mktime(0,0,0,$month-1,1,$year));

注意到类的错误,你必须打开错误:http://php.net/manual/en/function.error-reporting.php

error_reporting(E_ALL); 

更多关于PHP错误信息

关于字符似乎是一个编码问题:

这些链接将帮助您:

http://www.php.net/manual/en/ini.core.php#ini.default-charset

UTF-8 all the way through