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

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

问题描述

我有一个变量 $ var

我想要echo true 如果 $ var 等于以下任何值 abc def hij klm nop 。有没有办法用一个语句来做这个,比如&& ??

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如果具有多个条件的语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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