<?php
bool boolval ( mixed $var )
where,
$var = The BOOLEAN value of a VARIABLE
?>
<?php
$xyz = "STRING DELIMITED BY \"DOUBLE QUOTATION MARKS\"";
$str0 = 'STRING DELIMITED BY SINGLE QUOTATION MARKS';
$carÇ = 'STRING DELIMITED BY SINGLE "QUOTATION MARKS"';
$_alo = "STRING DELIMITED BY DOUBLE 'QUOTATION MARKS'";
$rquo = " » ";
$str01 = "1AnVXY234";
$str02 = "1234567";
// HEREDOC
$str03h = <<<EOD
Easy come, easy go.
If you can’t beat them, join them.
Life begins at forty.
Two heads are better than one.
EOD;
$str04h = <<<EOT
In PHP there are TWO types
of variables:
INTERNAL, (predefined).
OF USER: (user-defined).
EOT;
// NOWDOC
$str03n = <<<'EOD'
Easy come, easy go.
If you can’t beat them, join them.
Life begins at forty.
Two heads are better than one.
EOD;
$str04n = <<<'EOT'
In PHP there are TWO types
of variables:
INTERNAL, (predefined).
OF USER: (user-defined).
EOT;
echo boolval($carÇ) . '<br><br>' .
boolval($_alo) . '<br><br>' . boolval($rquo) . '<br><br>' .
boolval($str01) . '<br><br>' . boolval($str02) . '<br><br>' .
boolval($str03h) . '<br><br>' . boolval($str04n) . '<br><br>';
?>
<?php
function sboolval02 ($xvar)
{
if(boolval($xvar))
{
var_dump($xvar);
echo '<br>Conversion to BOOLEAN is possible<br><br>';
}
else
{
var_dump($xvar);
echo '<br>Conversion to BOOLEAN is NOT possible<br><br>';
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$vv01 = $_SERVER['REMOTE_ADDR'];
$vv02 = $_SERVER['HTTP_USER_AGENT'];
$vv03 = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
$vv04 = M_E;
$vv05 = 1.6e-19;
$vv06 = [ 'c' => 299792458, 'G' => 6.67428E-11 ];
$vv07 = NULL;
$vv08 = true;
$vv09 = FALSE;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sboolval02($vv02);
sboolval02($vv04);
sboolval02($vv05);
sboolval02($vv06);
sboolval02($vv07);
sboolval02($vv08);
sboolval02($vv09);
?>
<?php
function sboolval03 ($xvar)
{
if(boolval($xvar))
{
var_dump($xvar);
echo '<br>Conversion to BOOLEAN is possible<br><br>';
}
else
{
var_dump($xvar);
echo '<br>Conversion to BOOLEAN is NOT possible<br><br>';
}
}
$vv06a = [ 'c' => 299792458, 'G' => 6.67428E-11 ];
$vv07a = [ 2, 8, 18, 32, 32, 18, 8 ];
sboolval03($vv06a);
sboolval03($vv07a);
?>