note 49371 deleted from language.operators.arithmetic by hholzgra

From: Date: Thu, 02 Aug 2012 15:03:48 +0000
Subject: note 49371 deleted from language.operators.arithmetic by hholzgra
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-189798@lists.php.net to get a copy of this message
Note Submitter: justin at koivi dot com ---- A note about the documentation on this page that I found while teaching a PHP class: The above statment: "The division operator ("/") returns a float value anytime, even if the two operands are integers (or strings that get converted to integers)." is NOT TRUE. Take the following: <?php $a=5; $b=10; $c=$b/$a; $d=10/5; var_dump($c); var_dump($d); var_dump($b/$a); var_dump(10/5); ?> All 4 instances will print "int(2)" Therefore, the division operator "/" returns an integer value if the numbers are evenly divisible AND they are both integers (or strings that have been converted to integer values).

« previous php.notes (#189798) next »