programming-examples/php/Math/PHP script to get the information regarding memory usage in KB or MB etc.php

6 lines
260 B
PHP
Raw Permalink Normal View History

2019-11-15 12:59:38 +01:00
<?php
$memory_size = memory_get_usage();
$memory_unit = array('Bytes','KB','MB','GB','TB','PB');
// Display memory size into kb, mb etc.
echo 'Used Memory : '.round($memory_size/pow(1024,($x=floor(log($memory_size,1024)))),2).' '.$memory_unit[$x]."\n";
?>