本文整理汇总了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));
}