SMRTR ProgrammingOct 19, 2025Daily.dev

The three nothings of PHP

SMRTR summary

PHPians have three different flavors of nothing, and surprisingly, none of them get along.

While mathematicians wrestle with different sizes of infinity, PHP developers must navigate null, void, and uninitialized typed properties. Each represents the absence of data, yet they're completely incompatible with one another.

Null might seem like the obvious choice for nothingness, but it's paradoxically something that represents nothing. You can add to null and get an integer, or assign null to make a property unavailable. The old (unset) operator used to typecast values to null, though now the unset() function handles that job.

Void serves as null's equivalent for types, used in method return types. But here's where it gets strange: void and null aren't compatible. Returning null in a void method triggers an error because nothing can be returned, not even null.

Then there's the newest nothing: uninitialized typed properties. Unlike traditional PHP behavior where undefined properties default to null, these create a fatal error when accessed. They hold a special nothing that simply cannot be used until written to.

This trinity of nothingness creates intriguing questions about the very nature of absence in programming.

SMRTR provides this summary for quick context. The original article belongs to Daily.dev.

Read the original article
SMRTR Programming

Get the next batch of curated summaries in your inbox.

This archive is built from SMRTR newsletter summaries. Subscribe for hand-picked stories without the extra noise.