Hallo zsuammen,
gibts es eine Möglichkeit die Seriennummer vom Pi mit PHP auszugeben?
Gruß
Martin
Hallo zsuammen,
gibts es eine Möglichkeit die Seriennummer vom Pi mit PHP auszugeben?
Gruß
Martin
Seriennummer mit PHP ausgeben? Schau mal ob du hier fündig wirst!
Welche genau meinst du? Die vom CPU?
Ja genau...
In reinem/nativen PHP sähe das so aus:
[code=php]
<?php
$cpuinfolines = file("/proc/cpuinfo");
foreach($cpuinfolines AS $line) {
if (preg_match("/Serial.*:(.*)/", $line, $find)) {
echo $find[1];
break;
}
}
?>
[/php]
Natives PHP sollte man immer bevorzugen da schneller.
Du kannst aber auch Konsolen Befehle nutzen:
[code=php]
<?php
exec("/bin/grep '^Serial' /proc/cpuinfo | awk {'print $3'}", $output, $return_var);
echo $output[0];
?>
[/php]Sieht kürzer aus, ist aber unsauber/unschön und langsamer
Don’t have an account yet? Register yourself now and be a part of our community!