Can I say if (4 <$ a <44) instead of if (4 <$ a && $ a <44)? (PHP)

Can I use if(4 <= $a <= 44)instead if(4 <= $a && $a <= 44)?

+3
source share
4 answers

No, you cannot do this.

if(4 <= $a <= 44)equivalent to if((4 <= $a) <= 44). This may be equivalent to if(false <= 44)or if(true <= 44), none of which makes sense.

+10
source

No, you can’t.  

if(4 <= $a <= 44)will (I believe) be parsed as if ((4 <= $a) <= 44), which checks that (4 <= $a)(i.e. 0 or 1) is less than 44.

+4
source

+3

, ( ).

PHP, ,

4 <= $a <= 44

. .

+2

Source: https://habr.com/ru/post/1744417/


All Articles