Get total available system memory with PHP on Windows

前端 未结 2 533
梦毁少年i
梦毁少年i 2021-02-14 10:53

Using PHP, I\'d like to get the total memory available to the system (not just the free or used memory).

On Linux it\'s quite straight forward. You can do:

2条回答
  •  执笔经年
    2021-02-14 11:41

    This is a minor (and possibly more suitable for SuperUser) distinction, but as it's come up for me in a recent windows service, I'll provide it here. The question asks about available memory, not total physical memory.

    exec('wmic OS get FreePhysicalMemory /Value 2>&1', $output, $return);
    $memory = substr($output[2],19);
    
    echo $memory;
    

提交回复
热议问题