PHP 8.5.0 Alpha 2 available for testing

Voting

: min(one, zero)?
(Example: nine)

The Note You're Voting On

bishop at php dot net
9 years ago
In a similar vein, converting flags to booleans proper:

<?php
function return_boolean($val)
{
static
$map = array ('on' => true, 'true' => true, 'off' => false, 'false' => false);
return @(
$map[strtolower($val)] ?: (bool)$val);
}
?>

If you're using PHP >= 7, consider replacing ?: with ?? and removing the @ silencer.

<< Back to user notes page

To Top