这是我挑剔的......但目前我必须\
在我所有的班级面前使用......
//credit card expiration years and months
$expirationYears = array();
$expirationMonths = array();
$datePeriod = new \DatePeriod(new \DateTime(), new \DateInterval("P1Y"), 5);
foreach ($datePeriod as $year) {
$expirationYears[] = $year->format('Y');
}
$datePeriod = new \DatePeriod(new \DateTime('January 1st'), new \DateInterval("P1M"), 11);
foreach ($datePeriod as $month) {
$class = new \stdClass();
$class->value = $month->format('m');
$class->label = $month->format('M');
$expirationMonths[] = $class;
}
有没有办法解决这个问题,或者这只是命名空间环境中需要的东西?
我认为use
为每个班级指定一个是不合理的......这太乏味而无法维护