The former post describe how to "
Install LAMP web server on Raspberry Pi". We can create a PHP page (/var/www/testphp.php) to display system and memory info of Raspberry Pi on our web page.
<?php
list($system, $host, $kernel) = split(" ", exec("uname -a"), 5);
$meminfo = file("/proc/meminfo");
$infodetails = "<b>memory info</b><br/>";
for ($i = 0; $i < count($meminfo); $i++) {
list($item, $data) = split(":", $meminfo[$i], 2);
$item = chop($item);
$data = chop($data);
$infodetails .= $i." : ".$item." = ".$data."<br/>";
}
?>
<html>
<head>
<title>Hello Raspberry Pi</title>
</head>
<body>
<ul>
<li><?php echo $system ?></li>
<li><?php echo $host ?></li>
<li><?php echo $kernel ?></li>
</ul>
<?php echo $infodetails; ?><br/>
</body>
</html>
|
Display system and memory info of Raspberry Pi with PHP |
No comments:
Post a Comment