Php 使用会话中的值(不工作)选择该选项

Php 使用会话中的值(不工作)选择该选项,php,Php,我试图将所选属性赋予存储在会话中的年份(在我发布的脚本中,日期1990-06-27就是我所说的会话)。对于$month来说一切都很顺利,但是当我做同样的事情时,如果$year的语句不起作用,我真的不知道为什么 list($y,$m,$d)=explode('-', "1990-06-27"); for($month=1; $month<=12; $month++) { $monthName = date("F", mktime(0, 0, 0, $month));

我试图将所选属性赋予存储在会话中的年份(在我发布的脚本中,日期1990-06-27就是我所说的会话)。对于$month来说一切都很顺利,但是当我做同样的事情时,如果$year的语句不起作用,我真的不知道为什么

list($y,$m,$d)=explode('-', "1990-06-27");     
for($month=1; $month<=12; $month++) {
    $monthName = date("F", mktime(0, 0, 0, $month));
    $month = date("m", mktime(0, 0, 0, $month));
    $luni = array ('January' => 'Ianuarie', 'February' => 'Februarie', 'March' =>     'Martie', 'April' => 'Aprilie', 'May' => 'Mai', 'June' => 'Iunie', 'July' => 'Iulie', 'August' => 'August', 'September' => 'Septembrie', 'October' => 'Octombrie', 'November' => 'Noiembrie', 'December' => 'Decembrie');
        If($m === $month) { 
            $selected = 'selected="selected"';
            $monthOptions .= "<option value=\"{$month}\" $selected>{$luni[$monthName]}</option>\n";
        } else {
            $monthOptions .= "<option value=\"{$month}\">{$luni[$monthName]}</option>\n";
        }
}

$an_curent = date("Y", time());
for($year = $an_curent - 80; $year <= $an_curent - 16; $year++) {
    If($y === $year) { 
        $selected = 'selected="selected"';
        $yearOptions .= "<option value=\"{$year}\" $selected>{$year}</option>\n";  
    } else {
        $yearOptions .= "<option value=\"{$year}\">{$year}</option>\n";  
    }
}
list($y,$m,$d)=爆炸('-',“1990-06-27”);
对于($month=1;$month'Ianuarie'、'二月'=>'Februarie'、'Martie'、'April'=>'Aprilie'、'Mai'、'June'=>'Iunie'、'July'=>'Iulie'、'August'=>'August'、'Maury'=>、'Mai'、'July'=>'Iunie'、'July'=>'Iulie'、'August'、'August'、'August'、'August'、'Maury;
如果($m==$month){
$selected='selected=“selected”';
$monthOptions.=“{$luni[$monthName]}\n”;
}否则{
$monthOptions.=“{$luni[$monthName]}\n”;
}
}
$an_curent=日期(“Y”,time());

对于($year=$an\u curent-80;$year
$year
是一个整数,而
$y
是一个字符串。 因此,
==
运算符总是返回false。 使用
==
应该可以解决这个问题