PHP IF else 准时
$today=date("d"); # today
$startdate="14"; # start of advent 14th/13th
$enddate="25"; # end of advent 24th/25th
//strtomtime
?>
<!DOCTYPE HTML><html><head><meta charset="utf-8"><title>Christmas Advant Calendar</title></head><body>
<div class="adventframework">
<?php
/*$i=$startdate;
while($i<=$enddate)
{
echo "<div class='datebox " . $i . "' id='" . $i ."'>";
echo "Today is the " . $i . "";
echo "</div>";
$i++;
}*/
if ($startdate==$today){
echo 'today and start date match';
}
问题是今天是 01,但脚本回显:当 $startdate 为 14 时,今天和开始日期匹配 - 我应该使用我在这里;它去哪儿了?
$today=date("d"); # today
$startdate="14"; # start of advent 14th/13th
$enddate="25"; # end of advent 24th/25th
//strtomtime
?>
<!DOCTYPE HTML><html><head><meta charset="utf-8"><title>Christmas Advant Calendar</title></head><body>
<div class="adventframework">
<?php
/*$i=$startdate;
while($i<=$enddate)
{
echo "<div class='datebox " . $i . "' id='" . $i ."'>";
echo "Today is the " . $i . "";
echo "</div>";
$i++;
}*/
if ($startdate==$today){
echo 'today and start date match';
}
The problem is that today is 01
and yet the script echos: today and start date match
when $startdate
is 14 - I am supposed to use strtotime I here; where does it go?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题在于类型转换。
尝试
在设置 $startdate 上执行更多操作,例如:
The problem is typecasting.
Try doing
More over set $startdate like:
尝试使用
strcmp()
演示:http://codepad.org/lN90FUSa
Try using
strcmp()
Demo: http://codepad.org/lN90FUSa