memory.php > OX_getMemoryLimitSizeInBytes()

概要

  • PHPのメモリ制限の取得
  • バイト単位の整数で返す
  • 戻り値が-1の場合、無制限

引数

なし

実装

function OX_getMemoryLimitSizeInBytes() {
  • 設定オプションからメモリ制限を取得
  • 空または、-1で-1を返す
.   $phpMemoryLimit = ini_get('memory_limit');
    if (empty($phpMemoryLimit) || $phpMemoryLimit == -1) {
        // No memory limit
        return -1;
    }
    $aSize = array(
        'G' => 1073741824,
        'M' => 1048576,
        'K' => 1024
    );
    $phpMemoryLimitInBytes = $phpMemoryLimit;
    foreach($aSize as $type => $multiplier) {
        $pos = strpos($phpMemoryLimit, $type);
        if (!$pos) {
            $pos = strpos($phpMemoryLimit, strtolower($type));
        }
        if ($pos) {
            $phpMemoryLimitInBytes = substr($phpMemoryLimit, 0, $pos) * $multiplier;
        }
    }
    return $phpMemoryLimitInBytes;
}

コメント

タグ:

+ タグ編集
  • タグ:
最終更新:2011年05月01日 02:00
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。