The first idea that comes into mind for doing this is to simply make a typecast of the boolean variable to a string and use that (which works)
$testVar = false; echo (string)$testVar; //will output a empty string (as that evaluates to false) $testVar = true; echo (string)$testVar; //will output 1 (as that evaluates to true) |
but what if the requirement is that the string should say true or false
$testVar = false; echo $testVar ? 'true' : 'false'; //will output false $testVar = true; echo $testVar ? 'true' : 'false'; //will output true |
(While the above example might seam useless I recently had to do this for a db insert)