I have some of radio buttons and checkboxes elements in my HTML form which holds 0 as value. typically i would check for the required values using two functions isset() or !empty() while isset() works quite well without hindrance but this is not the case with empty() as logically 0 represents boolean and hence empty(0) returns true. which is kind of bug when you evaluates integer 0 using empty(). i would like to know the workaround so that it evaluates integer empty(0) as false. one solution i could think of was using strlen($variable) >= 1 , is there any better way or it is fine using strlen()?
thank you
You can check if a variable is exactly a value with three equals:
===will only be true if the variable is actually 0.