ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
PHPMemoryLimit.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
27 trait PHPMemoryLimit
28 {
29  public function getSizeLimitInBytes(): int
30  {
31  $memory_limit = ini_get('memory_limit');
32  if (preg_match('/^(\d+)(.)$/', $memory_limit, $matches)) {
33  $memory_limit = match ($matches[2]) {
34  'K' => $matches[1] * 1024,
35  'M' => $matches[1] * 1024 * 1024,
36  'G' => $matches[1] * 1024 * 1024 * 1024,
37  default => $memory_limit,
38  };
39  }
40  return (int) $memory_limit;
41  }
42 }