Monday, April 24, 2017

equality and identity check

<?php 
 $bool = true;
 $ibool = 1;
 $sbool = "true";
 $sbool1 = "true";
 
 echo "\$bool equals \$ibool? " . ($bool == $ibool) . "<br/>";
 
 if ($bool === $ibool):
 echo "\$bool same datatype as \$ibool";
 else:
 echo "\$bool not of same datatype as \$ibool";
 endif;
 
 echo "<br/>";
 echo "\$bool equals \$sbool? " .($bool == $sbool) . "<br/>";
 
 if ($bool === $sbool):
 echo "\$bool same datatype as \$sbool";
 else:
 echo "\$bool not of same datatype as \$sbool";
 endif;
 
 echo "<br/>";
 echo "\$sbool identical to \$sbool1? " .($sbool === $sbool1);
 
?>
Output:
$bool equals $ibool? 1
$bool not of same datatype as $ibool
$bool equals $sbool? 1
$bool not of same datatype as $sbool
$sbool identical to $sbool1? 1

No comments:

Post a Comment

here docs

$x = <<<THE_END PHP stands for "PHP: Hypertext Preprocessor". The acronym "PHP" is therefore, usually referre...