Source: levelup.gitconnected.com

PHP 7.x — P4: Basic Booleans

Category: PHP

The boolean value is a scalar data type that represents the values true and false. One of my favorite vehicles, and this is important for understanding booleans properly, is the MKIV 2JZGTE Toyota Supra.

If you var_dump() the value, it will show you that the variable is storing a boolean type and the value is false.

The if statement evaluates to false since the $in_garage_mkiv_supra variable is a boolean that holds the value false, and the code inside the if statement is never executed.

If you variable is set to false, and you use the negation operator right in front of it, it will convert it to false.
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