A
A
Alexey selftrips.ru2018-03-01 16:55:02
PHP
Alexey selftrips.ru, 2018-03-01 16:55:02

How to write if x = a or x = b?

if ( $x == $a or $x == $b )
if ( ($x == $a) or ($x == $b) )
if ( $x == ($a or $b) )

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
Nick Sdk, 2018-03-01
@lidacriss

if ($x == $a || $x == $b)

G
GreatRash, 2018-03-01
@GreatRash

switch ($x) {
  case $a:
  case $b:
    // делаем всякое
    break;
  default: // ничего не делаем
}

A
Alexander Lykasov, 2018-03-02
@lykasov-aleksandr

Just in case, I will draw your attention to the difference between "or" and "||": php.net/manual/en/language.operators.logical.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question