带有多个条件的 PHP If 语句 [英] PHP If Statement with Multiple Conditions

查看:41
本文介绍了带有多个条件的 PHP If 语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个变量$var.

如果 $var 等于以下任意值 abc, def 我想要 echo "true">、hijklmnop.有没有办法用一个像 &&??

I want echo "true" if $var is equal to any of the following values abc, def, hij, klm, or nop. Is there a way to do this with a single statement like &&??

推荐答案

if($var == "abc" || $var == "def" || ...)
{
    echo "true";
}

我认为使用或"代替和"会有所帮助

Using "Or" instead of "And" would help here, i think

这篇关于带有多个条件的 PHP If 语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆