本文整理匯總了PHP中PMA_getRealSize函數的典型用法代碼示例。如果您正苦於以下問題:PHP PMA_getRealSize函數的具體用法?PHP PMA_getRealSize怎麽用?PHP PMA_getRealSize使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了PMA_getRealSize函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: checkUploadSize
/**
* Maximum upload size as limited by PHP
* Used with permission from Moodle (http://moodle.org) by Martin Dougiamas
*
* this section generates $max_upload_size in bytes
*
* @return void
*/
function checkUploadSize()
{
if (!($filesize = ini_get('upload_max_filesize'))) {
$filesize = "5M";
}
if ($postsize = ini_get('post_max_size')) {
$this->set('max_upload_size', min(PMA_getRealSize($filesize), PMA_getRealSize($postsize)));
} else {
$this->set('max_upload_size', PMA_getRealSize($filesize));
}
}
示例2: PMA_getRealSize
*
* @param string $size size
*
* @return integer $size
*/
function PMA_getRealSize($size = 0)
{
/*
if (! $size) {
return 0;
}
*/
$scan['gb'] = 1073741824;
//1024 * 1024 * 1024;
$scan['g'] = 1073741824;
//1024 * 1024 * 1024;
$scan['mb'] = 1048576;
$scan['m'] = 1048576;
$scan['kb'] = 1024;
$scan['k'] = 1024;
$scan['b'] = 1;
foreach ($scan as $unit => $factor) {
if (strlen($size) > strlen($unit) && substr($size, strlen($size) - strlen($unit)) == $unit) {
return substr($size, 0, strlen($size) - strlen($unit)) * $factor;
}
}
return $size;
}
$in = user_input();
echo PMA_getRealSize($in) . "\n";
示例3: testUnspecified
public function testUnspecified()
{
$this->assertEquals(1024, PMA_getRealSize('1024'));
}
示例4: testNull
/**
* Test for
*
* @param string $size Size
* @param int $expected Expected value
*
* @return void
*
* @dataProvider provider
*/
public function testNull($size, $expected)
{
$this->assertEquals($expected, PMA_getRealSize($size));
}