Boolean type
Pages 0 from 51
Questions 0 from 84
Reset
* Boolean
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
* NULL
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
* Boolean
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
* NULL
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
More from Php








More from Programming


Powered by minte9.com