You are here

private static function Database::getMemoryLimit in Smart IP 6.2

Same name and namespace in other branches
  1. 7.2 includes/vendor/ip2location/ip2location-php/IP2Location.php \IP2Location\Database::getMemoryLimit()

Get memory limit from the current PHP settings (return false if no memory limit set)

@access private @static

Return value

int|boolean

1 call to Database::getMemoryLimit()
Database::__construct in includes/vendor/ip2location/ip2location-php/IP2Location.php
Constructor

File

includes/vendor/ip2location/ip2location-php/IP2Location.php, line 828

Class

Database
IP2Location database class

Namespace

IP2Location

Code

private static function getMemoryLimit() {

  // Get values if no cache
  if (null === self::$memoryLimit) {
    $limit = ini_get('memory_limit');

    // Feal with defaults
    if ('' === (string) $limit) {
      $limit = '128M';
    }
    $value = (int) $limit;

    // Deal with "no-limit"
    if ($value < 0) {
      $value = false;
    }
    else {

      // Deal with shorthand bytes
      switch (strtoupper(substr($limit, -1))) {
        case 'G':
          $value *= 1024;
        case 'M':
          $value *= 1024;
        case 'K':
          $value *= 1024;
      }
    }
    self::$memoryLimit = $value;
  }
  return self::$memoryLimit;
}