Simple Advice
This is just a reminder. When setting environment variables through .htaccess, CLI or dotenv use filter_var()
to evaluate a boolean. For example, start the built-in PHP server with these variables:
DEBUG=FALSE LOG=TRUE SMS=1 SMTP=0 CONNECT=yes BACKUP=no php -d variables_order=EGPCS -S localhost:8000
And then test through boolval()
: if you forget to use 1 and 0, then something can go wrong as the variable is evaluated like a string and will always return TRUE
. By using filter_var()
, with the appropriate filter to validate boolean, you get more flexibility as it:
returns TRUE for "1", "true", "on" and "yes". Returns FALSE otherwise.