我正在运行一个php程序control.php,它调用另一个程序functions.php,但是有一个错误 我的课程如下:
CONTROL.PHP
$sleeptime = 125000;
require("functions.php");
$temp = $_SERVER['argv'][1];
if (is_numeric($temp)) {
if ($temp >= 66 && $temp <= 88) {
echo "Setting temperature to {$temp}F...\n";
flush();
usleep($sleeptime);
reset_ac();
$up = $temp - 66;
updeg($up);
echo "Done.\n";
} else {
echo "Temperature must be a number between 66 and 88!\n";
}
} else {
echo "Temperature must be a number!\n";
}
的functions.php
//relay control board functions
$relay['ip'] = "192.168.10.180";
$relay['read'] = "public";
$relay['write'] = "private";
$relay['base'] = ".1.3.6.1.4.1.19865.1.2.";
$relay['base'] = ".1.3.6.1.4.1.19865.1.2.";
$relay['num'][1] = "1.1.0";
$relay['num'][2] = "1.2.0";
$relay['num'][3] = "1.3.0";
$relay['num'][4] = "1.4.0";
$relay['num'][5] = "1.5.0";
$relay['num'][6] = "1.6.0";
$relay['num'][7] = "1.7.0";
$relay['num'][8] = "1.8.0";
$relay['num'][9] = "2.1.0";
$relay['num'][10] = "2.2.0";
$relay['num'][11] = "2.3.0";
$relay['num'][12] = "2.4.0";
$relay['num'][13] = "2.5.0";
$relay['num'][14] = "2.6.0";
$relay['num'][15] = "2.7.0";
$relay['num'][16] = "2.8.0";
$relay['num'][17] = "3.1.0";
$relay['num'][18] = "3.2.0";
$relay['num'][19] = "3.3.0";
$relay['num'][20] = "3.4.0";
$relay['num'][21] = "3.5.0";
$relay['num'][22] = "3.6.0";
$relay['num'][23] = "3.7.0";
$relay['num'][24] = "3.8.0";
//returns the value of the specified relay
function getrelay($val) {
global $relay;
$data = snmpget($relay['ip'],$relay['read'],"{$relay['base']}{$relay['num'][$val]}");
return $data;
}
//sets a specified relay on or off
function setrelay($val, $val2) {
global $relay;
$data = snmpset($relay['ip'],$relay['write'],"{$relay['base']}{$relay['num'][$val]}","i","$val2","0");
return $data;
}
//resets all relays to off
function clear() {
for ($a = 1; $a <= 16; $a++) {
setrelay($a, 0);
}
}
function reset_ac() {
global $sleeptime;
echo "Resetting to 66F";
for ($a = 1; $a <= 22; $a++) {
setrelay(1,1);
echo ".";
flush();
usleep($sleeptime);
setrelay(1,0);
flush();
usleep($sleeptime);
}
echo " Done.\n";
}
function updeg($deg) {
global $sleeptime;
echo "Stepping up {$deg}F";
for ($a = 1; $a <= $deg; $a++) {
setrelay(2,1);
echo ".";
flush();
usleep($sleeptime);
setrelay(2,0);
flush();
usleep($sleeptime);
}
echo " Done.\n";
}
function downdeg($deg) {
global $sleeptime;
echo "Stepping up {$deg}F";
for ($a = 1; $a <= $deg; $a++) {
setrelay(1,1);
echo ".";
flush();
usleep($sleeptime);
setrelay(1,0);
flush();
usleep($sleeptime);
}
echo " Done.\n";
}
错误显示为致命错误:无法在第44行的/root/functions.php中定义snmpset()
请帮忙