"true" or "false" values not converted properly to boolean
php-wizard opened this issue · comments
php-wizard commented
Hello,
i am using codemix\yii2confload\Config class,
and i have this variable in my .env file:
PAYPAL_API_LIVE=false
at some point i read that variable
$live = Config::env("PAYPAL_API_LIVE");
Then i use it like this:
curl_setopt($ch, CURLOPT_URL, "https://svcs" . ($live ? "" : ".sandbox") . ".paypal.com/AdaptivePayments/$method");
and the resulting CURLOPT_URL is going to be https://svcs.paypal.com/AdaptivePayments/ConvertCurrency
as the $live variable is the string "false" , which is true when evaluated as boolean.
How can i tell codemix\yii2confload\Config to parse "true" and "false" as Boolean ?
Michael Härtl commented
Use 0
and 1
instead and to be perfectly safe: $live = (bool) Config::env('PAYPAL_API_LIVE')
.