~/talk

Top 10 PHP Classic Traps

Talkat PHP Yorkshire 2019 · 2019-04-03..04-04· [php, testing]
slides:none on file

Covers concrete pitfalls and fixes: use strpos() === false not == to avoid confusing 0 with false; prefer const over define() for compile-time constants (case‑insensitive define() is deprecated since 7.3 and removed in 8.0); replace repeated concatenation/print with echo or collect and join to avoid reallocations; buffer CSV into php://memory with fputcsv then write once; beware operator precedence (and vs &&), foreach by reference leak unless unset, unset properties become missing, DateTime intervals not strtotime month arithmetic, and use hrtime() on PHP 7.3+ for monotonic timing.

AI-written summary · about

  1. 0:00Introduction and setup
  2. 2:28Strpos false vs zero trap
  3. 5:42Constant defining performance
  4. 10:02Echo vs print concatenation
  5. 15:02CSV writing performance
  6. 18:34Operator precedence confusion
  7. 23:21Logical operators and types
  8. 25:29Variable variable injection
  9. 27:17Real vs float deprecation
  10. 28:24String character access
  11. 29:50Substring vs strtolower order
  12. 32:45Array merging inefficiency
  13. 37:09Double square bracket quirks
  14. 40:25Regex optional capture trap
  15. 42:08Column names vs indices
  16. 44:17Unsetting class properties
  17. 47:06Date calculation pitfalls
  18. 51:09Script timing accuracy
  19. 52:33Reference loop trap
  20. 55:28List short syntax updates
  21. 56:56Array destructuring
  22. 57:59Top 10 recap and conclusion
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.