3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* get system resource precentages */ function serverStatus() { /* cpu usage */ $cpuUsage=NULL; exec('ps -aux', $processes); foreach($processes as $process){ $cols = split(' ', ereg_replace(' +', ' ', $process)); if (strpos($cols[2], '.') > -1){ $cpuUsage += floatval($cols[2]); } } $sysLoad = sys_getloadavg(); /* get raspberry pi temp */ $rawTemp = shell_exec('/opt/vc/bin/vcgencmd measure_temp'); /* trim temp= from the response */ $temp_c = round(str_replace("temp=", "", $rawTemp),2); $temp_f = round((($temp_c * 9) / 5) + 32,2); /* memory usage */ foreach(file('/proc/meminfo') as $ri) $m[strtok($ri, ':')] = strtok(''); /* displays memory used precentage */ $memory = 100 - round(($m['MemFree'] + $m['Buffers'] + $m['Cached']) / $m['MemTotal'] * 100); /* free memory in mB rounded to tenths */ $memoryFree = round($m['MemFree']/(1024), 2); /* Buffered memory in mB rounded to tenths */ $bufferedMem = round($m['Buffers']/(1024), 2); /* cached Memoty in mB and rounded to tenths */ $cachedMem = round($m['Cached']/(1024),2); /* total memory in mB rounded to tenths */ $TotleMem = round($m['MemTotal']/(1024),2); /* disk free space a gigabytes and rounded to tenths */ $freeSpace = round(disk_free_space("/")/(1024*1024*1024), 2); /* total disk space in gigabytes and rounded to tenths */ $totalSpace = round(disk_total_space("/")/(1024*1024*1024), 2); /* disk free space in precentage */ $freePrecent = round($freeSpace / $totalSpace * 100, 2); /* server uptime*/ $uptime = shell_exec("cut -d. -f1 /proc/uptime"); $days = floor($uptime/60/60/24); $hours = $uptime/60/60%24; $mins = $uptime/60%60; $secs = $uptime%60; /* current server time */ $obsTime= date("g:i a" ,time()).' on '.date("l, F d, Y" ,time()); /* build status array */ $status=array( 'cpu' => $cpuUsage.' %', 'system load' => $sysLoad, 'cpu temp_c' => $temp_c.' C', 'cpu temp_f' => $temp_f.' F', 'memory' => $memory.' %', 'memory free' => $memoryFree.' mB', 'buffered memory' => $bufferedMem.' mB', 'memory cached' => $cachedMem.' mB', 'total memory' => $TotleMem.' mB', 'free gb' => $freeSpace.' gB', 'free precent' => $freePrecent.' %', 'total gb' => $totalSpace.' gB', 'uptime' => $days.' days '.$hours.' hours '.$mins.' minutes and '.$secs.' seconds', 'observation time' => $obsTime ); return $status; } serverStatus();
Output for 7.4.0
Warning: file(): open_basedir restriction in effect. File(/proc/meminfo) is not within the allowed path(s): (/tmp:/in:/etc) in /in/GaMZ9 on line 20 Warning: file(/proc/meminfo): failed to open stream: Operation not permitted in /in/GaMZ9 on line 20 Warning: Invalid argument supplied for foreach() in /in/GaMZ9 on line 20 Notice: Undefined variable: m in /in/GaMZ9 on line 22 Notice: Trying to access array offset on value of type null in /in/GaMZ9 on line 22 Notice: Undefined variable: m in /in/GaMZ9 on line 22 Notice: Trying to access array offset on value of type null in /in/GaMZ9 on line 22 Notice: Undefined variable: m in /in/GaMZ9 on line 22 Notice: Trying to access array offset on value of type null in /in/GaMZ9 on line 22 Notice: Undefined variable: m in /in/GaMZ9 on line 22 Notice: Trying to access array offset on value of type null in /in/GaMZ9 on line 22 Warning: Division by zero in /in/GaMZ9 on line 22 Notice: Undefined variable: m in /in/GaMZ9 on line 24 Notice: Trying to access array offset on value of type null in /in/GaMZ9 on line 24 Notice: Undefined variable: m in /in/GaMZ9 on line 26 Notice: Trying to access array offset on value of type null in /in/GaMZ9 on line 26 Notice: Undefined variable: m in /in/GaMZ9 on line 28 Notice: Trying to access array offset on value of type null in /in/GaMZ9 on line 28 Notice: Undefined variable: m in /in/GaMZ9 on line 30 Notice: Trying to access array offset on value of type null in /in/GaMZ9 on line 30 Warning: disk_free_space(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/tmp:/in:/etc) in /in/GaMZ9 on line 32 Warning: disk_total_space(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/tmp:/in:/etc) in /in/GaMZ9 on line 34 Warning: Division by zero in /in/GaMZ9 on line 36
Output for 7.1.25 - 7.1.33, 7.2.0 - 7.2.25, 7.3.0 - 7.3.12
Warning: file(): open_basedir restriction in effect. File(/proc/meminfo) is not within the allowed path(s): (/tmp:/in:/etc) in /in/GaMZ9 on line 20 Warning: file(/proc/meminfo): failed to open stream: Operation not permitted in /in/GaMZ9 on line 20 Warning: Invalid argument supplied for foreach() in /in/GaMZ9 on line 20 Notice: Undefined variable: m in /in/GaMZ9 on line 22 Notice: Undefined variable: m in /in/GaMZ9 on line 22 Notice: Undefined variable: m in /in/GaMZ9 on line 22 Notice: Undefined variable: m in /in/GaMZ9 on line 22 Warning: Division by zero in /in/GaMZ9 on line 22 Notice: Undefined variable: m in /in/GaMZ9 on line 24 Notice: Undefined variable: m in /in/GaMZ9 on line 26 Notice: Undefined variable: m in /in/GaMZ9 on line 28 Notice: Undefined variable: m in /in/GaMZ9 on line 30 Warning: disk_free_space(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/tmp:/in:/etc) in /in/GaMZ9 on line 32 Warning: disk_total_space(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/tmp:/in:/etc) in /in/GaMZ9 on line 34 Warning: Division by zero in /in/GaMZ9 on line 36
Output for 7.1.0 - 7.1.7
Notice: A non well formed numeric value encountered in /in/GaMZ9 on line 22 Notice: A non well formed numeric value encountered in /in/GaMZ9 on line 22 Notice: A non well formed numeric value encountered in /in/GaMZ9 on line 22 Notice: A non well formed numeric value encountered in /in/GaMZ9 on line 22 Notice: A non well formed numeric value encountered in /in/GaMZ9 on line 24 Notice: A non well formed numeric value encountered in /in/GaMZ9 on line 26 Notice: A non well formed numeric value encountered in /in/GaMZ9 on line 28 Notice: A non well formed numeric value encountered in /in/GaMZ9 on line 30
Output for 5.1.3 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.2
Fatal error: Call to undefined function sys_getloadavg() in /in/GaMZ9 on line 13
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: sys_getloadavg() in /in/GaMZ9 on line 13
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
Fatal error: Call to undefined function: sys_getloadavg() in /in/GaMZ9 on line 13
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: sys_getloadavg() in /in/GaMZ9 on line 13

preferences:
220.45 ms | 401 KiB | 261 Q