dongtui2029 2013-05-14 00:04 采纳率: 0%
浏览 63
已采纳

php mktime函数产生奇怪的符号

I am trying to adapt a calendar script by David Walsh. In David's script showing a monthly calendar, for the first week it shows blanks before the month start but a commenter said you can use following code to display the dates from the previous month ie 28 20 30 depending on when the first day of the month falls.

I won't repeat all of the code from the script linked to, but the main thing is that the replacement code displays a symbol I have never seen before.., �30�. (I have copied these symbols from he source. They are squares that say FF above PD.). Here is code. Note $x, $running_day and $daysInThisWeek are just numbers. $calendar gets echoed at end.

//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;

//But following, echoed, prints out wierd symbols:

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

Then when you loop through as above you get a whole bunch of the wierd symbols.

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

Does anyone know what might be going on, what the wierd symbols mean and how to get this to display properly.

Thanks for any suggestions!

  • 写回答

2条回答 默认 最新

  • douchen5971 2013-05-14 00:11
    关注

    Turn on all errors and you will see that you have wrong quotes. Errors would be like

    Notice: Use of undefined constant ‘t’ - assumed '‘t’'

    This line

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

    must be

    $daysInLastMonth = date('t',mktime(0,0,0,$month-1,1,$year));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用