我有一页上面有肚脐按钮。另外,我使用一个超音波无线开关,打开/关闭一盏灯。
我正在努力使这个任务有序地工作。
代码power_off.php
<?php
session_start();
unset($_SESSION['valid']);
unset($_SESSION['timeout']);
header( "url=http://192.168.2.2/cs?cmnd=Power%20Off" );
header( "refresh:2;url=http://www.google.gr/" );
?>
谢谢。
发布于 2020-09-21 06:41:10
修改断电脚本的解决方案:
在您的输入脚本中:
<?php
session_start();
unset($_SESSION['valid']);
unset($_SESSION['timeout']);
header( "Location: http://192.168.2.2/cs?cmnd=Power%20Off" );
?>
然后在该文件的末尾,使您添加电源的文件
sleep(2); //if you want to wait 2 seconds...
header( "Location: http://www.google.gr/" );
exit;
具有CURL:的解决方案
<?php
session_start();
unset($_SESSION['valid']);
unset($_SESSION['timeout']);
//Initialize cURL.
$ch = curl_init("http://192.168.2.2/cs?cmnd=Power%20Off");
//Execute the request.
curl_exec($ch);
//Close the cURL handle.
curl_close($ch);
sleep(2); //wait for 2 seconds. Remove if not needed.
header( "Location: https://www.google.com" ); //redirect to Google
exit;
?>
https://stackoverflow.com/questions/63986879
复制相似问题