我有以下代碼snipplet:列表(),如果和短路評價
$active_from = '31-12-2009';
if(list($day, $month, $year) = explode('-', $active_from)
&& !checkdate($month, $day, $year)) {
echo 'test';
}
爲什麼我得到一個未定義的變量錯誤?
list($day, $month, $year) = explode('-', $active_from)
返回true
,所以list()
被評估,不是嗎?我認爲,應該定義變量?我要監督什麼?
這並不在我看來相同,不引發錯誤:
$active_from = '31-12-2009';
list($day, $month, $year) = explode('-', $active_from);
if(checkdate($month, $day, $year)) {
echo 'test';
}
這引發任何錯誤:
if((list($day, $month, $year) = explode('-', $active_from)) && checkdate($month, $day, $year)) {
但我真的不明白,爲什麼:-)
感謝您的解釋
這裏沒有錯誤http://codepad.org/33BV3EsO –