Posts tagged with magic

Join 9,500+ smart developers

Get my monthly newsletter with what I learn from running Spatie, building Oh Dear, and maintaining 300+ open source packages. Practical takes on Laravel, PHP, and AI that you can actually use.

No spam. Unsubscribe anytime. You can also follow me on X.

When empty is not empty original

by Freek Van der Herten – 2 minute read

Recently when I was working on a project I got some strange results when using the empty function. Here's what I was debugging. I've simplified the code a bit to share with you. var_dump( $person->firstName, empty($person->firstName) ); This was the result: string(5) "Freek"…

Read more

A magic memoization function original

by Freek Van der Herten – 4 minute read

Last friday Taylor Otwell tweeted an easy to use memoization function called once: Wanted a slick way to generalize class method memoization. Y'all don't even want to know how it works. ? ? pic.twitter.com/xRJAY1C14y— Taylor Otwell (@taylorotwell) November 4, 2016 Taylor was kind…

Read more

Voodoo PHP

If you're interested in some dark magic you should watch this talk by Marco Pivetta on Voodoo PHP. I really like these show-me-the-code type of talks.

We've often seen "magic" code, but how does it even work? Let's explore some arguably bad PHP coding techniques that are actually used in real world libraries to solve problems that would otherwise be a huge burden for all of us.

Read more