note 32063 deleted from function.intval by cmb

From: Date: Sun, 16 Feb 2020 13:54:27 +0000
Subject: note 32063 deleted from function.intval by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-214157@lists.php.net to get a copy of this message
Note Submitter: Robin Y. Millette http://rym.waglo.com ---- Rob_Kohr at no_need_to_email dot me dot com 11-Nov-2002 12:24 [snip] $var=intval("122.5"); //$var==122 This is nice if you want to turn a double into an int automatically rounding down Hum, I had a bug earlier today, involving ===. Coming from a c++ background, I can't help testing for types. I was using floor() to get an integer from a division by 2, and comparing that to a known integer from a for loop. Well, first I changed the === to == because the test would always be false otherwise. Next, I looked up this function, and converted most of my floor() calls to intval() calls, because I really meant to get an int, and not a float with no decimal part. So I have to disagree with the editor note here. Oh, and I'm comfortably back to using ===.

« previous php.notes (#214157) next »