PHP 8.2.20 Released!

Voting

: three plus zero?
(Example: nine)

The Note You're Voting On

Anonymous
18 years ago
In reply to VGR_experts_exchange at edainworks dot com

To check if a constant is boolean, use this instead:

<?php
if (TRACE === true) {}
?>

Much quicker and cleaner than using defined() and constant() to check for a simple boolean.

IMO, using ($var === true) or ($var === false) instead of ($var) or (!$var) is the best way to check for booleans no matter what. Leaves no chance of ambiguity.

<< Back to user notes page

To Top