Are these two statements executed identically, given $thing could be of any type?
if (!empty($thing)) {
    // do stuff
}
if ($thing) {
    // do stuff
}
I'm aware I could try it, but I'm not sure I'd catch all the edge cases... I'm afraid in some situations they would execute identically, but not all.
If $thing is undefined, then if ($thing) would throw a (non-fatal) error while if (!empty($thing)) would return false.
See empty() in the PHP documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With