Skip to content

Instantly share code, notes, and snippets.

@trueqap
Created May 18, 2018 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trueqap/99fda0c97e0d6d98e568e39c7e61bc8c to your computer and use it in GitHub Desktop.
Save trueqap/99fda0c97e0d6d98e568e39c7e61bc8c to your computer and use it in GitHub Desktop.
<?php
$memory_limit = ini_get('memory_limit');
if (preg_match('/^(\d+)(.)$/', $memory_limit, $matches)) {
if ($matches[2] == 'M') {
$memory_limit = $matches[1] * 1024 * 1024; // nnnM -> nnn MB
} else if ($matches[2] == 'K') {
$memory_limit = $matches[1] * 1024; // nnnK -> nnn KB
}
}
$ok = ($memory_limit >= 640 * 1024 * 1024); // at least 64M?
echo '<phpmem>';
echo '<val>' . $memory_limit . '</val>';
echo '<ok>' . ($ok ? 1 : 0) . '</ok>';
echo '</phpmem>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment