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

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners