5 ms·
I was thinking about the part where you check the cache with if (!$found) On that note, I adapted a rule of an open source project (can't quite remember which)
by hendrik-xdest 15y ago
I was thinking about the part where you check the cache with if (!$found)
On that note, I adapted a rule of an open source project (can't quite remember which) that said to never use !$var to validate your data. One should always use isset($found['args']) or empty($found['args']) or for example is_array($found) && count($found) > 0 to check.
- antihero 15y agoI suppose I could use $var === False, to prevent it pick up empty results.
- Gigablah 15y agoI've been burnt by this in the past. Nowadays I use ($found === false) to check for a cache miss (though this means you can't store boolean values verbatim). This is why: !array() -> true !null -> true !false -> true !0 -> true !"0" -> true (!!?) !"" -> true