note 113640 added to class.invalidargumentexception

From: Date: Fri, 08 Nov 2013 14:21:48 +0000
Subject: note 113640 added to class.invalidargumentexception
Groups: php.notes 
Request: Send a blank email to php-notes+get-197466@lists.php.net to get a copy of this message
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; } ---- Server IP: 72.52.91.14 Probable Submitter: 72.52.91.14 ---- Manual Page -- http://php.net/manual/en/class.invalidargumentexception.php Edit -- https://master.php.net/note/edit/113640 Del: integrated -- https://master.php.net/note/delete/113640/integrated Del: useless -- https://master.php.net/note/delete/113640/useless Del: bad code -- https://master.php.net/note/delete/113640/bad+code Del: spam -- https://master.php.net/note/delete/113640/spam Del: non-english -- https://master.php.net/note/delete/113640/non-english Del: in docs -- https://master.php.net/note/delete/113640/in+docs Del: other reasons-- https://master.php.net/note/delete/113640 Reject -- https://master.php.net/note/reject/113640 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#197466) next »