note 71049 added to function.ini-get
| From: | d0uglasemart1natgma1ldotc0m0=o1=i at osu1 dot php dot net | Date: | Thu, 09 Nov 2006 16:34:30 +0000 |
| Subject: | note 71049 added to function.ini-get | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-119562@lists.php.net to get a copy of this message | ||
In case you are a little confused by the conversion code above it makes use of the fact that there
are no breaks in the switch which allows the code to fall more than 1 case.
It's a fun hack but I don't think it makes for very readable code (at least without a
comment). I'd recomment something more readable like:
function return_bytes($val) {
$val = trim($val);
switch (strtolower(substr($val, -1, 1))) {
// The 'G' modifier is available since PHP 5.1.0
case 'g':
$val *= 1024 * 1024 * 1024; break;
case 'm':
$val *= 1024 * 1024; break;
case 'k':
$val *= 1024; break;
}
return $val;
}
----
Server IP: 64.71.164.2
Probable Submitter: 71.192.101.106
----
Manual Page -- http://www.php.net/manual/en/function.ini-get.php
Edit -- https://master.php.net/note/edit/71049
Del: integrated -- https://master.php.net/note/delete/71049/integrated
Del: useless -- https://master.php.net/note/delete/71049/useless
Del: bad code -- https://master.php.net/note/delete/71049/bad+code
Del: spam -- https://master.php.net/note/delete/71049/spam
Del: non-english -- https://master.php.net/note/delete/71049/non-english
Del: in docs -- https://master.php.net/note/delete/71049/in+docs
Del: other reasons-- https://master.php.net/note/delete/71049
Reject -- https://master.php.net/note/reject/71049
Search -- https://master.php.net/manage/user-notes.php