Types
Back to PHP
Booleans
Booleans test whether something is true or falseExample: -
<?php
$mybool = True;
//Now test it
if($mybool)
echo "The result is true";
else
echo "The result is false";
?>
Integers
Integers are whole numbers which can either be positive or negative. This includes hexadecimal and octal numbers. Hexadecimal numbers start with a 0, followed by a x and then the hex number. Octal numbers start with 0Example: -
<?php
$a = 1234; // decimal number
$a = -123; // a negative number
$a = 0123; // octal number (equivalent to 83 decimal)
$a = 0x1A; // hexadecimal number (equivalent to 26 decimal)
?>
Floating point numbers
Are decimal number e.g. has a remainderExample: -
<?php
$a = 1.234;
$b = 1.2e3;
$c = 7E-10;
?>
Strings
Strings are for storing alphabetic, numbers and symbolsExample: -
<?php
$a = "Hello World";
$b = "1 + 2 = 3";
?>