Write Clean PHP Code (or “else”)

Photo by Roman Bozhko on Unsplash
Behold, a perfectly normal-looking PHP function

Start With Default Values

$key = false by default

Return Early and Often

Why go through the whole function, when we know the return value early enough?

Be Explicit, Not Implicit

return true? or false?

Prefer Form Over Function

What the hell?

SOURCE: https://levelup.gitconnected.com/write-clean-php-code-or-else-aac64bb9ae

Zachary Flower


Zachary Flower

Professional nerd, avid indoorsman, aspiring polymath.
Level Up Coding

Level Up Coding