If I want to take action, if php, if the variable is not 0.1 or 2, how would I do it? my if statement does not work. Thank!
if (($var != 0) && ($var != 1) && ($var != 2)) { //... }
or...
if (!in_array($var, array(0, 1, 2))) { /* ... */ }
See logical operators .
The easiest way:
if ($x != 0 && $x != 1 && $x != 2) { // take action! }
If you know your variable is int, you can also do the following:
if ($x < 0 || $x > 2) { // take action! }
&& !==, :
&&
!==
if( $n !== 0 && $n !== 1 && $n !== 2 ) { // it not any of those values. }
== , :
==
. . == vs. ===. " ", , , , . , if( $n < 0 || $n > 2 ) . (, , .)
===
if( $n < 0 || $n > 2 )
&& ||.
||
Source: https://habr.com/ru/post/1760849/More articles:Superfish popup menu not working in IE7 - jqueryCLLocationManager - странный утечка памяти - memory-leaksEffective drawing of 2D sprites (bitmaps) - c #endless jQuery cookie - javascriptThe order in which CSS rules are displayed in Chrome Developer Tools - cssJAva: why is nothing written in my txt file? - javaПерехват событий щелчка на элементахкоторые программно добавлены в DOM - javascriptHow to use MediaController.MediaPlayerControl? - androidClose multiple Safari windows with applescript - applescriptКак группировать перечисления, структуры и подклассы в классах? - c#All Articles