Expert Refresh

Boolean type

1) What is the output? <?php echo ((boolean) 0) !== TRUE; echo ((boolean) 99) === FALSE;

2) What is the output? <?php echo ((boolean) '0') !== FALSE; echo ((boolean) '00') === FALSE;

3) What is the output? <?php echo (boolean) "00"; echo (int) "a";


A number converted into boolean became false if the original value is zero, and true otherwise. <?php echo ((boolean) 0) !== TRUE; // output 1 echo ((boolean) 99) === TRUE; // output 1 A string is converted to false only if its empty or '0'. If it contains any other data (even multiple zeros) it is converted to true. <?php echo ((boolean) '0') === FALSE; // output 1 echo ((boolean) '00') === FALSE; // output nothing

Array - Are containers of data elements

Object - Are containers of both data and code


A variable is considered to be NULL if it has been assigned the special value NULL, or if it has not yet been assigned a value at all.

Converting Between Data Types

PHP takes care of converting between data types transparently. However, it is still possible to force the conversion of a value to a specific type <?php $x = 10.88; echo (int) $x; // output 10