Recently, I posted a question about if ( $a == $b or $a == $c )
expression. Now I want to know if there's also a shorthand expression for this code:
if ( $a == $b && $a == $c ) { /*statement*/ }
That code can be read like "if $a is equal to $b and $a is equal to $c".
Is there code that's more shorter that can be read like:
if ( $a is equal to ( $b and $c ) ) { /*statement*/ }
Because you are testing if $a is equal to $b and $c this logically results in $b being equal to $c, I don't know how much shorter this would be but if you wanted to quickly test if all prepossed values are the same you could create an array of them and call array_unique
. If the length of the resulting array is 1 then they are all equal to each other. I imagine this would only be easier if you had a large set of values, as the syntax might obscure your intent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With