Tamam. Buna ne dersin.
It checks whether $mo and $mc are valid dates using is_numeric
. Any NULL or false values will be caught by that.
I haven't tested it but it should work.
Ben kod büyük bir blok içine yayıldı. Dil öğrenme zaman Başlangıçta, bu kodun anlam çıkarmak için en iyi yoldur. Bu kısa çözüm en zarif, ne kadar değildir. Daha sonra, boşluk kaldırarak onu kısaltmak veya or
ve malzeme getirerek yapabilirsiniz.
Ben sayı karşılaştırma bölümü hakkında% 100 emin değilim, ve ben şu anda bunu kontrol etmek için vaktim yok. Bunu çalışıp çalışmadığını denemek gerekecek.
Eğer hataları işlemek ve benim yorum nerede kodu eklemek istiyorum nasıl karar vermeniz gerekir. Basit bir echo
zaten yapabilir.
// If $mo or $mc are false, show error.
// Else, proceed to checking whether $mo is larger
// than $mc.
if ((!is_numeric($mo)) and (is_numeric($mc)))
{
// Error: $mo is either NULL, or false, or something else, but not a number.
// While $mc IS a number.
}
elseif ((!is_numeric($mc)) and (is_numeric($mo)))
{
// Error: $mc is either NULL, or false, or something else, but not a number.
// While $mo IS a number.
}
else
{
if (($mc <= $mo) and ((is_numeric($mc) or (is_numeric($mo)))))
{
// Error: closing time is before opening time.
}
else
{
// Success!!
}
}