note 96996 added to function.ini-get

From: Date: Fri, 26 Mar 2010 18:08:06 +0000
Subject: note 96996 added to function.ini-get
Groups: php.notes 
Request: Send a blank email to php-notes+get-167437@lists.php.net to get a copy of this message
another version of return_bytes which returns faster and does not use multiple multiplications (sorry:). even if it is resolved at compile time it is not a good practice; no local variables are allocated; the trim() is omitted (php already trimmed values when reading php.ini file); strtolower() is replaced by second case which wins us one more function call for the price of doubling the number of cases to process (may slower the worst-case scenario when ariving to default: takes six comparisons instead of three comparisons and a function call); cases are ordered by most frequent goes first (uppercase M-values being the default sizes); specs say we must handle integer sizes so float values are converted to integers and 0.8G becomes 0; 'Gb', 'Mb', 'Kb' shorthand byte options are not implemented since are not in specs, see http://www.php.net/manual/en/faq.using.php#faq.using.shorthandbytes <?php function return_bytes ($size_str) { switch (substr ($size_str, -1)) { case 'M': case 'm': return (int)$size_str * 1048576; case 'K': case 'k': return (int)$size_str * 1024; case 'G': case 'g': return (int)$size_str * 1073741824; default: return $size_str; } } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 82.66.245.193 ---- Manual Page -- http://www.php.net/manual/en/function.ini-get.php Edit -- https://master.php.net/note/edit/96996 Del: integrated -- https://master.php.net/note/delete/96996/integrated Del: useless -- https://master.php.net/note/delete/96996/useless Del: bad code -- https://master.php.net/note/delete/96996/bad+code Del: spam -- https://master.php.net/note/delete/96996/spam Del: non-english -- https://master.php.net/note/delete/96996/non-english Del: in docs -- https://master.php.net/note/delete/96996/in+docs Del: other reasons-- https://master.php.net/note/delete/96996 Reject -- https://master.php.net/note/reject/96996 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#167437) next »