Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. /**
  2. * getMemoryLimit allow to get the memory limit in octet
  3. *
  4. * @since 1.4.5.0
  5. * @return int the memory limit value in octet
  6. */
  7. public static function getMemoryLimit()
  8. {
  9. $memory_limit = @ini_get('memory_limit');
  10.  
  11. return Tools::getOctets($memory_limit);
  12. }
  13.  
  14. /**
  15. * getOctet allow to gets the value of a configuration option in octet
  16. *
  17. * @since 1.5.0
  18. * @return int the value of a configuration option in octet
  19. */
  20. public static function getOctets($option)
  21. {
  22. if (preg_match('/[0-9]+k/i', $option))
  23. return 1024 * (int)$option;
  24.  
  25. if (preg_match('/[0-9]+m/i', $option))
  26. return 1024 * 1024 * (int)$option;
  27.  
  28. if (preg_match('/[0-9]+g/i', $option))
  29. return 1024 * 1024 * 1024 * (int)$option;
  30.  
  31. return $option;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement