~/talk

Top 10 PHP coding traps

Talkat Dutch PHP Conference 2020 · on Friday, 2020-06-26· [php]
slides:none on file

Static analysis across many PHP projects finds concrete patterns and fixes: 26 ambiguous string functions that return 0/false confusion (php8 adds str_contains), 13 OpenSSL-like functions that return -1/0/1 so boolean checks hide errors, and a measured 2% use of case-insensitive constants. Recommendations include replacing define() with const, using echo with multiple args, buffer fputcsv into php://memory then rewind to avoid repeated disk flushes, and prefer foreach/hoisted count or variadic array_merge to avoid repeated reallocations.

AI-written summary · about

  1. 0:00Intro
  2. 1:06Top 10 PHP classic traps
  3. 3:48strpos(), the legendary
  4. 5:06The real face of strpos()
  5. 8:00The lesser legend of strpos()
  6. 12:24define() is on the way out
  7. 13:49Constant static expressions
  8. 18:00echo doesn't "function"
  9. 18:27A reverse problem
  10. 20:43Dump it like Beckam
  11. 22:40Logic, written in full
  12. 25:16Order matters
  13. 29:25A matter of string
  14. 31:20Sneak master level 100
  15. 33:02Far from reality
  16. 33:33I want the magic property
  17. 35:25Looping with array_merge()
  18. 40:09Looping with concat
  19. 42:21Looping with addition
  20. 43:25Missing subpattern
  21. 46:41Want to check your code?
~/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.