使用PHP获取用户输入

时间:2016-11-05 10:57:36

标签: php input raspberry-pi

处理一个简单的项目,我可以在浏览器的地址栏中键入192.168.x.xx/?$n,然后Raspberry Pi将发送一个pwm信号(使用WiringPi库),该信号等同于变量{{1}到一个LED。我刚开始使用PHP,这就是我在这里需要帮助的原因。我现在想到的是:

$n

非常感谢任何帮助和指示。

1 个答案:

答案 0 :(得分:2)

你必须通过这样的URL输入数据......

192.168.x.xx/?data=n                //n is of type int


//php script
<?php
$n=$_GET['data'];
exec("gpio mode 1 pwm");
//declare $n as a variable (integer maybe)
//$n = the user input value from browser (I only know $_GET, pretty sure it's not this right?)
exec("gpio pwm 1 ".$n);
?>
相关问题