Q:

Write a PHP script to get the information regarding memory usage in KB or MB etc

0

Write a PHP script to get the information regarding memory usage in KB or MB etc.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<?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";
?>

Sample Output:

Used Memory : 342.57 KB

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now