Home >Backend Development >PHP Tutorial >判断$_post的值

判断$_post的值

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-23 13:30:581384browse

1.$_post的值如何判断?

if(isset($_POST["username"])=""){echo"kong";}elseif(isset($_POST["username"])!="admin"){echo"kong";}


上面的写法对吗?


回复讨论(解决方案)

if(isset($_POST["username"]) && $_POST["username"] == '') {  echo"kong";}elseif(isset($_POST["username"]) && $_POST["username"] != "admin") {  echo"kong";}

if (isset($_POST['username']) && (empty($_POST['username']) || $_POST['username'] !== 'admin')) {    echo 'kong';//空或不等于admin} elseif (isset($_POST['username']) && $_POST["username"] == 'admin') {    echo "yes";//管理员}

if(isset($_POST["username"]) && $_POST["username"] == '') {  echo"kong";}elseif(isset($_POST["username"]) && $_POST["username"] != "admin") {  echo"kong";}


if(!isset($_POST["username"]) && $_POST["username"] == '')
多谢!

if (isset($_POST['username']) && (empty($_POST['username']) || $_POST['username'] !== 'admin')) {    echo 'kong';//空或不等于admin} elseif (isset($_POST['username']) && $_POST["username"] == 'admin') {    echo "yes";//管理员}


判断非空还可以用empty来。。。学习了!
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:搭建PHP建站环境Next article:PHP中的异常处理