Properly drafted condition?

Properly drafted condition?
(If the variable type is not equal to not equal to MX or SRV)
if ($type !='MX' OR 'SRV')
June 27th 19 at 15:15
2 answers
June 27th 19 at 15:17
Solution
if ($type !='MX' AND $type != 'SRV')
A short form is unacceptable. - Glennie_Beie commented on June 27th 19 at 15:20
: well, only if
if (!in_array($type, ['MX', 'SRV'])) {
if (!in_array($type, ['MX', 'SRV'], true)) {

php.net/manual/ru/function.in-array.php - Violet_Wiso commented on June 27th 19 at 15:23
June 27th 19 at 15:19
To test equality use ONLY ===
For inequality !==

php.net/manual/ru/language.operators.comparison.php
if ($type !=='MX' AND $type !== 'SRV')
Is it possible to use the short form?
if ($type !=='MX' OR 'SRV') - Glennie_Beie commented on June 27th 19 at 15:22
: This is not a short form.
var_dump((bool) 'SRV'); - Violet_Wiso commented on June 27th 19 at 15:25

Find more questions by tags PHP