如果未设置 isset - php

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7333404/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 02:30:14  来源:igfitidea点击:

if isset not set - php

php

提问by X10nD

if(isset($_POST['text1']) && isset($_POST['text2'])) {

echo "xxxxxx";
echo "yyyyyyyyyy";


} else {
?>
<form>

</form>


<?php

}


?>

When isset is not set I want the form shown and when submitted form not shown, using PHP. This code when ! isset is activated, form is not shown, is it coding or syntax error

未设置isset 时,我希望使用PHP 显示表单,但未显示提交的表单时。这段代码当!isset 已激活,表单未显示,是否编码或语法错误

回答by Pawan Choudhary

Just place a "!" in front of your if else statement's conditions,
Make sure that $_POST['text1'] and $_POST['text2'] are not already set in your php script itself.

只需放置一个“!” 在 if else 语句的条件之前,
确保 $_POST['text1'] 和 $_POST['text2'] 尚未在您的 php 脚本中设置。

<?php
if(!isset($_POST['text1']) && !isset($_POST['text2'])) {

echo "xxxxxx";
echo "yyyyyyyyyy";


} else {
?>
<form>

</form>


<?php

}


?>

回答by genesis

if(!(isset($_POST['text1']) && isset($_POST['text2']))) {
    echo "xxxxxx";
    echo "yyyyyyyyyy";
} else {
?>
<form>

</form>
<?php
}
?>

回答by X10nD

I got the problem, there was nothing with the code, the only problem was

我遇到了问题,代码没有任何问题,唯一的问题是

Forgot to add php after

后面忘记加php了

Silly me..

傻我..

Thanks for all the assistance.

感谢所有的帮助。