note 113640 deleted from class.invalidargumentexception by cmb

From: Date: Wed, 28 Sep 2016 14:57:27 +0000
Subject: note 113640 deleted from class.invalidargumentexception by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-206697@lists.php.net to get a copy of this message
Note Submitter: edsonhoraciojunior at gmail dot com ---- A version of Joey's code that validates if the number really isn't int: function tripleInteger($int) { // if is a number and is not float (doesn't have a decimal separator) if(is_numeric($int) && strpos($int, ".") === false) { $int = intval($int); } if(!is_int($int)) throw new InvalidArgumentException('tripleInteger function only accepts integers. Input was: '.$int); return $int * 3; }

« previous php.notes (#206697) next »