empty怎么样判断多个变量

WBOY
Release: 2016-06-23 14:12:18
Original
1147 people have browsed it

如果一个IF语句用empty来判断多个变量怎么办,我试过好像不可以

$top='33';$metop='';if(empty($top)&&empty($metop)){  //这个地方可以用&& 来判断么,就是$top和$metop为空就提示,并且退出  echo '为空';  exit;}echo 'thank you!';   //如果上面为空,这里的地方也就不会显示出来了.
Copy after login


回复讨论(解决方案)

if(empty($top) || empty($metop)){ //用或 || 只要一个为空就进入。

$top='33';
$metop='';
$foo = array('foo'=>$top, 'bar'=>$metop);
$bar = implode('', $foo);
if (empty($bar)) {
   echo "EMPTY!";
} else {
   echo "NOT EMPTY!";
}

$top='33';
$metop='';
$foo = array('foo'=>$top, 'bar'=>$metop);
$bar = implode('', $foo);
if (empty($bar)) {
   echo "EMPTY!";
} else {
   echo "NOT EMPTY!";
}
为什么不直接用$top.$metop啊

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template