Category: PHP, javascript

The code looks for the null check for each property before going onto the next chain of the property/method. It do so by storing the intermediate values in the buffer properties in each condition and go on for the null check on the next property in the chain.

How this works is when the left hand side of the operator evaluates to null the execution of the entire chain will stop and evalute to null.

This is called as short-circuiting which means when the evaluation of one element in the chain fails the execution of the entire chain is aborted and the entire chain evaluates to null. This is really convient as it effectively reduces the number of line of the code and in addition to that there would be less chance of the human error as you don’t check for the null checks explicitly.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners