- 3

Bad example if ($age > 18)

good examle: if ($age >= 18)

14th Jul 2017, 4:04 PM
SnowCat
3 Respostas
+ 2
in what context?
14th Jul 2017, 4:14 PM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
+ 2
? I don't understand, both are good, it depends on the situation. In most situations I'd use ($age > 18) so I can check if my user is an adult or not.
14th Jul 2017, 4:42 PM
mexikodro thanksgiving samples 1/1
mexikodro thanksgiving samples 1/1 - avatar
+ 2
Both are good, simply by the fact than in integer context $age >=18 is strictly equivalent to $age > 17... In a floating point context, that's not strictly equivalent, but > or >= are good or bad depending of the context, not in absolute ^^
14th Jul 2017, 4:53 PM
visph
visph - avatar