You can use the sys_get_temp()
function to get the CPU temperature in Celsius and then convert it to Fahrenheit using the formula (Celsius * 1.8) + 32
. Here's a code snippet that shows how to do this:
main.php115 chars4 lines
Note that this function only works on Linux-based systems with support for the lm-sensors
package installed. If you're running PHP on Windows or another non-Linux system, you'll need to use a different method to get the CPU temperature.
gistlibby LogSnag