未定义变量:$sameday at somthing.php
我将在something.php上为特色活动编写此代码未定义变量:$sameday at somthing.php,php,error-handling,Php,Error Handling,我将在something.php上为特色活动编写此代码 $day_start = date("j", mktime(0,0,0,$event_start_month, $event_start_day, $event_start_year)); $day_end = date("j", mktime(0,0,0, $event_end_month, $event_end_day, $event_end_year)); if (($day_start == $day_end
$day_start = date("j", mktime(0,0,0,$event_start_month, $event_start_day, $event_start_year));
$day_end = date("j", mktime(0,0,0, $event_end_month, $event_end_day, $event_end_year));
if (($day_start == $day_end)) {
$same_day = true;
}
<?php if ($same_day == false) { ?>
<span class="value value-date"> - <?php echo $day_end; ?></span>
您应该始终为
$same\u day
分配一些内容,以避免出现此警告。像这样:
if (($day_start == $day_end)) {
$same_day = true;
} else{
$same_day =false; // <-- This is the new part.
}
...
if ($same_day == false) {
if($day\u start==$day\u end)){
$same_day=正确;
}否则{
$same_day=false;//使用此选项可避免错误
$same_day = false;
if (($day_start == $day_end)) {
$same_day = true;
}
......
<?php if ($same_day == false) { ?>
<?php echo $day_end; ?>
$same\u day=false;
如果($day\u start==$day\u end)){
$same_day=正确;
}
......
if (($day_start == $day_end)) {
$same_day = true;
} else{
$same_day =false; // <-- This is the new part.
}
...
if ($same_day == false) {
$same_day = false;
if (($day_start == $day_end)) {
$same_day = true;
}
......
<?php if ($same_day == false) { ?>
<?php echo $day_end; ?>