HTML
:
echo "<form action='procSS.php' method='get'>\n";
echo "<button style='color:black;' type='submit' name='start' value='" . $data[0]\ . "'> start </button>";
echo "<button style='color:black;' type='submit' name='stop' value='" . $data[0] . \"'> stop </button>";
echo "</form>";
procSS.php
<?php
$server_conn = stream_socket_client("tcp://127.0.0.1:9000", $errno, $errmsg);
echo intval(0);
if($_GET['start'] == null || $_GET['stop'] == null) {
echo "its null my dude";
}
if(!empty($_GET['start'])) {
fwrite($server_conn, "Start ".$_GET['start']."");
echo "Start ".$GET_['start'];
fclose($server_conn);
} elseif(!empty($_GET['stop'])) {
fwrite($server_conn, "Stop ".$_GET['stop']."");
echo "Stop ".$_GET['stop'];
fclose($server_conn);
} elseif(!empty($_GET['reset'])) {
fwrite($server_conn, "Restart ".$_GET['reset']."");
fclose($server_conn);
} else {
echo "???";
}
?>
好的,这就是网址 - &gt; http://localhost/procSS.php?stop=0
并且它清楚地发送0. php页面上的输出是:0its null my dude???
。所以我做了intval(0)它返回0.接下来我们看到$ _GET ['stop']是空的,即使它通过0.为什么这个以及如何解决它? intval(0)为0,但是通过get传递0是空的
答案 0 :(得分:0)
因为它们都是假的0是假的,当用于条件
时null也是假的像这样使用严格类型检查(===)0 === null