note 35772 added to function.checkdate
| From: | jlamberg at cc dot helsinki dot fi dot invalid | Date: | Sun, 14 Sep 2003 09:57:07 +0000 |
| Subject: | note 35772 added to function.checkdate | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-56463@lists.php.net to get a copy of this message | ||
A validity enhancement to the previous note using is_numeric in addition to checkdate:
Since the checkdate function has a bug in it (bug #25530), I think you should be checking for
is_int() instead of is_numeric(), at least before the bug is fixed.
// Example 1
$day = "4e4";
$mon = "5";
$year = "2000";
if (is_numeric($day) && is_numeric($mon) &&
is_numeric($year) && checkdate( $mon, $day, $year ))
{
echo "Valid 1";
}
// Result: prints 'Valid 1'
// Example 2
if (is_int($day) && is_int($mon) &&
is_int($year) && checkdate( $mon, $day, $year ))
{
echo "Valid 2";
}
// Result: prints nothing
I hope you can see the difference.
----
Manual Page -- http://www.php.net/manual/en/function.checkdate.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35772
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35772&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35772&report=yes