note 30191 added to function.fmod
| From: | fjeanson at yahoo dot com | Date: | Mon, 10 Mar 2003 02:16:20 +0000 |
| Subject: | note 30191 added to function.fmod | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-45055@lists.php.net to get a copy of this message | ||
For those of you still using PHP 4.1.X and below.. fmod is not available. You can easily check if a
variable a multiple of 2 by doing the following which is compatible with 4.1.X and below:
$var; //variable to check if multiple of 2 or not
$stype = gettype($var/2); //returns the type of the result.
if($stype == "integer"){
echo "$var is a multiple of two! Yay!";
} else {
echo "$var is NOT a multiple of two! Yay, I guess!";
}
since 3/2 = 1.5 its a float..
4/2 = 2 its an integer..
$stype will be equal to "double" if the variable is a float.. for historical reasons.
voila.
--
http://www.php.net/manual/en/function.fmod.php
http://master.php.net/manage/user-notes.php?action=edit+30191
http://master.php.net/manage/user-notes.php?action=delete+30191
http://master.php.net/manage/user-notes.php?action=reject+30191