ISSET()问题 [英] ISSET() question
问题描述
以下代码处理一个空白字段,好像它有一些值
并继续进行,好像它被设置为某个值。
显然isset( )是不行的,因为它认为空白文本
字段被设置为某种东西。
请让我知道如何正确使用isset()。
非常感谢。
<?php
if(!isset($ _ POST [''varA ''])||!isset($ _ POST [''varB''])){
?>
< form action =" isset.php" ; method =" POST">
< table>< tr>
< td>值1:< / td>< td>< input type =" text"名称= QUOT;翻" value ="">< / td>< /
tr>
< tr>< td>值2:< / td> < td>< input type =" text"名称= QUOT; varB" value ="">< /
td>< / tr>
< tr>< td colspan =" 2">< ; input type =" submit" value =" submit">< / td>< / tr>
< / table>
< / form>
<?php
}
else {
$ x = $ _ POST [''varA''];
$ y = $ _ POST [''varB''];
if($ x> $ y){
echoValue 1:。$ x。更大的;
}否则
echo" Value 2:"。$ y。"更大的;
}
?>
The following code processes a blank field as though it has some value
and proceeds as though it was set to some value.
Apparently isset() is not working, because it thinks that a blank text
field is set to something.
Please let me know how to use isset() correctly.
Thanks ahead.
<?php
if(!isset($_POST[''varA''])||!isset($_POST[''varB''])){
?>
<form action="isset.php" method="POST">
<table><tr>
<td>Value 1:</td><td><input type="text" name="varA" value=""></td></
tr>
<tr><td>Value 2:</td><td><input type="text" name="varB" value=""></
td></tr>
<tr><td colspan="2"><input type="submit" value="submit"></td></tr>
</table>
</form>
<?php
}
else {
$x=$_POST[''varA''];
$y=$_POST[''varB''];
if($x>$y){
echo "Value 1:".$x." is larger";
}else
echo "Value 2:".$y." is larger";
}
?>
推荐答案
_POST [''varA''])||!isset(
_POST[''varA''])||!isset(
_POST [''varB''])){
?>
< form action =" isset.php" method =" POST">
< table>< tr>
< td>值1:< / td>< td>< input type =" text"名称= QUOT;翻" value ="">< / td>< /
tr>
< tr>< td>值2:< / td> < td>< input type =" text"名称= QUOT; varB" value ="">< /
td>< / tr>
< tr>< td colspan =" 2">< ; input type =" submit" value =" submit">< / td>< / tr>
< / table>
< / form>
<?php
}
else {
_POST[''varB''])){
?>
<form action="isset.php" method="POST">
<table><tr>
<td>Value 1:</td><td><input type="text" name="varA" value=""></td></
tr>
<tr><td>Value 2:</td><td><input type="text" name="varB" value=""></
td></tr>
<tr><td colspan="2"><input type="submit" value="submit"></td></tr>
</table>
</form>
<?php
}
else {
x =
这篇关于ISSET()问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!