3 ms·
The rules are confusing, but if you want it loosely typed there isn't much else you can do. I have a few things I would change: empty('0') should be false n
by ars 18y ago
The rules are confusing, but if you want it loosely typed there isn't much else you can do.
I have a few things I would change:
empty('0') should be false not true
if('0') should be true as well
Comparing a string and int should convert the int to a string not the other way around.
But mostly the rules are logical.
- nuclear_eclipse 18y ago> Comparing a string and int should convert the int to a string not the other way around. No: '0007' == 7; #true By your logic: '0007' == 7; #false, wtf? And why the hell should `empty('0')` return false?! emtpy() determines if the value contains something. I would most certainly think that a string with even one character is not empty, even if it's a space.
- ars 18y agoI think you got the logic on empty backward :) Right now empty('0') is true - meaning php thinks it's empty (because '0' turns into 0 which turn into false). I think it should be the other way around, and so do you except you read what I wrote backwards. And I understand the problem of '0007' - but 'abc' == 0 is worse. Most of the time things in php are strings. If you know you'll have leading zeros, then you also know it once was a string, and you'll take measures like intVal. You need intVal to avoid SQL injection attacks anyway.