note 125272 deleted from language.types.boolean by cmb
| From: | cmb@php.net | Date: | Sat, 15 Aug 2020 08:09:32 +0000 |
| Subject: | note 125272 deleted from language.types.boolean by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-214971@lists.php.net to get a copy of this message | ||
Note Submitter: halfhearted13 at gmail dot com
----
let's make fun of boolean true and false..
<?php
$a = TRUE; // this will print integer 1.
$b = "5something22" + true; // from the string it will take 5 then +1 = 6
echo $a + $b; // prints 1 + 6 = 7
$c = 9.6 + true * 9; // true will be 1
echo $c; // prints 9.6 + 1*9 = 18.6. the number will be floating type.
//let's do more maths with boolean
echo (true/false); // prints: INF 1 for true,0 for false.so 1/0 = infinity
echo (true/true); // prints: 1 / 1 = 1
echo (false/true); // prints: 0 / 1 = 0
echo (false/true); // prints: 0 / 0 = NAN
echo (sqrt(-true)); // prints sqrt(-1) = NAN
echo (log(true)); // prints: log(1) = 0
echo (log(false)); // prints: log(0) = -INF it is minus infinity.
//let's do some trigonometry with boolean
echo (acos(true)); // prints: arc cos(1) = 0
echo (acos(-true)); // prints: arc cos(-1) = PI = 3.1415926535898
echo (acos(false)); //prints: arc cos(0) = PI/2 = 1.5707963267949
echo (acos(true+TRUE)); // prints: arc cos(1+1) = NAN
Awesome this is!! Isn't it?? (1 or 0)