PHP:测试三个变量是否相等 [英] PHP: Testing whether three variables are equal

查看:275
本文介绍了PHP:测试三个变量是否相等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以前从未遇到过,但是您如何测试三个变量是否相同?以下内容显然行不通,但我想不出一种优雅(正确)的方式来编写以下内容:

I've never come across this before, but how would you test whether three variables are the same? The following, obviously doesn't work but I can't think of an elegant (and correct) way to write the following:

if( $ select_above_average === $ select_average === $ select_below_average){}

推荐答案

if ((a == b) && (b == c)) {
   ... they're all equal ...
}

通过传递关系

这篇关于PHP:测试三个变量是否相等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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