CBool

 

Definition: Returns an expression that has been converted to a Variantof subtype Boolean.

 

Sure, you can convert a string or numeric value to a Boolean value (True or False): all you have to do is convert the data type of the variable to a Boolean type. As far as we know, 0 will always be converted to False and anything that isn't zero (even something as nonsensical as the string value cat) will be converted to True. In the following example we assign the value 0 to the variable $a, then convert $ a toa Boolean value:

 

$a = 0
$a = [ bool] $a

 

When you run this command and then echo back the value of $ a youshould get the following:

 

False