Php true/false values and conditions. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Php true/false values and conditions.

just a simple question: which values give true and which false... Know which in js...but this course can't give me answers even on half of my questuons :D how about Undefined,NaN,null... What will be result of comparing them... Type of this things.... Yeah..I google it up tomorrow anyway... But I guess you'll help others too :D Cause this is realy important thing...

9th Apr 2017, 10:36 PM
Rose Sevenyears
Rose  Sevenyears - avatar
5 Answers
+ 1
True 1,False 0.Undefined NaN and NULL totally specific things if you control a variable if its NULL you should write var=='NULL'
11th Apr 2017, 7:09 PM
Fuat Seven
Fuat Seven - avatar
0
Yeah...that's simple...but I was talkin' about other thing. 1.Which exectly values will give us 1 or 0. As example in js : any values exept undefined,null , NaN , "",0 will output false if we'll convert values into boolean type. How about php ? And other part: 2.What about comparing NaN with NaN, Undefined with Undefined or null with null... And null with NaN e.t.c. That's realy important thing everyone should know as i think. At least in js it's so. 3.What about types of NaN,Undefined,null ?
11th Apr 2017, 7:26 PM
Rose Sevenyears
Rose  Sevenyears - avatar
0
only 0 will give you 0 value other values except NaN undef or NULL will give you value 1 like 23000 will give you value 1 as for NaN or NULL controls as i said you control them like this:"var=='NaN'or'NULL'"
11th Apr 2017, 7:35 PM
Fuat Seven
Fuat Seven - avatar
0
and they all have uniqe types
11th Apr 2017, 7:36 PM
Fuat Seven
Fuat Seven - avatar
0
so... 0,undefined,NaN,null - 0 ; Any others 1 ? even empty string ? About control : user can input "NaN" or "Undefined",so var==NaN\Undefined just will not work here,exept we'll use ===... But even about it - not so sure,about how it works here. more about control: Is there way to control this special types for sure ? and still: What about comparing special types ?
11th Apr 2017, 9:02 PM
Rose Sevenyears
Rose  Sevenyears - avatar