我有这个 PHP 代码,它在 SELECT 框中填充前 10 年和未来 10 年的值。
<select name="fromYear"';
$starting_year =date('Y', strtotime('-10 year'));
$ending_year = date('Y', strtotime('+10 year'));
for($starting_year; $starting_year <= $ending_year; $starting_year++) {
echo '<option value="'.$starting_year.'">'.$starting_year.'</option>';
}
echo '<select>
如何让它自动选择当前年份?