Category tricks

Yoda conditions

Yoda conditions are a programming style, which goal is to prevent accidental assignments of variables within conditionals. Such as in the following situations. To prevent that, the constant is placed at the forefront of the statement, therefore raising an exception…

What are Heredoc and Nowdoc?

Most of the time, using a regular string for large outputs is not the optimal solution, especially if the content is spread across multiple lines. There’re several tricks to achieve the desired result with different levels of cleanliness. Instead of…

TIL: stdObject custom string keys

Hi there!For quite some time I’ve been using objects in a wrong way. Every time after a json_decode, I was by inertia casting the returned stdObject into an array to use with some more “special” keys. The ones with special…

TIL: strtotime function

While researching the `setcookie` function, another one caught my eye. Apparently, instead of writing the time of expiration in unix seconds, you can use human-readable format, neatly parsed by strtotime() ! It for sure improves the readability of the code,…