Bet you’ll learn at least one new PHP feature in this article?

I love to call them “hidden features”, even if everything’s in the documentation.

Alexandre Daubois
Geek Culture

--

Photo by Artezio on Unsplash

Pipe and exclamation mark both reset time part in DateTime format

I came across this one on Twitter lately, and it seems a lot of PHP developers were shocked by the existence of this feature — including me. If you ever need to reset the time part of a string you’re parsing as a DateTime, this could save you a few lines of code.

Multiple breaks and continues in one line

Yes, these expressions can take an integer argument! Of course they both act differently. Just take a look at the code snippet below which will worth a thousand words:

Read-only properties

Before this feature was implemented in the coming version of PHP, version 8.1 at the time of writing, there…

--

--

Alexandre Daubois
Geek Culture

Lead Developer at Wanadev // Open-source contributor