To get the system CPU temperature in Celsius using PHP, we can make use of the sys_get_temp_dir()
function to get the path to the system's thermal zone directory, and then read the contents of the temp
file to get the CPU temperature in milli-degrees Celsius. We can then convert the temperature to Celsius by dividing by 1000.
Here is the code:
main.php407 chars12 lines
Note: This code will only work on systems with thermal zones, such as Linux-based systems.
gistlibby LogSnag