e-bookcomputer.com – This tutorial discusses PHP Data Types, what are data types? PHP Data Types is the type or characteristic of a value that is accommodated on a variable, in all programming languages must have data types that are generally not different. In PHP itself, there are 8 (eight) types of data types that can be used to determine a value that is accommodated.
In some programming languages to determine the type of data type it must first declare it, in contrast to PHP, where writing data types do not need to be declared because PHP will automatically read the type of data type of a value, here are the types of data types in PHP and their explanation.
Before going forward, there are a number of articles that you might be looking for.
Integers are integer data types, can be either positive or negative integers, but integers support octal, decimal and hexadecimal numbers. Actually, the range of data types in PHP in the form of Integers is the same as the LONG data type in the C programming language, except that in C language standards it does not determine the length of the value of this data type, so it is possible for some systems to see different values.
$decimal = 1337;
echo "This is a decimal number: $decimal";
Example of Writing Octal Numbers
To write integer data types in the form of octal numbers must be preceded by a number 0 (zero) in front of it, for example.
Float data types can be called Floating-points and real numbers or commonly referred to as court numbers, for example, 2.5, 4.5 and others, examples of using float data types in PHP:
$a = 4.5;
$b = 3.5;
$result = $a + $b;
echo "Example of the sum of float data types 4.5 and 3.5, results: $result";
String Data Type
Data string types are used to hold values in the form of text and characters, strings can be a word or sentence because the type of string data types are text and characters, so arithmetic operations on this type of data type cannot be calculated, for example:
$string = 'This is a string data type';
Boolean Data Type
The type of boolean data type is the type to determine the logic of true or false conditions by using the values TRUE and FALSE, this type of data type does not affect uppercase and lowercase letters, besides to represent conditions the boolean data type can also use a value of 1 0 (FALSE), for example:
$a = TRUE;
$b = FALSE;
if ($ a == TRUE)
echo 'Variable $ a is worth TRUE';
echo '<br />';
if ($ b == FALSE)
echo 'Variable $ b is FALSE';
Array Data Type
An array is a variable that consists of a set of data where the data has the same data type and each data is stored at different memory addresses, many of which can be used by using arrays, for example to group the same data for example city names, years, and others. Here’s how to write an array:
$data = array ('Jakarta', 'Bogor', 'Depok', 'Tangerang', 'Bekasi');
echo 'This is an example of the name of the Jabodetabek city arranged in an array: <br />';
Before proceeding, there are a number of articles that might be looking for.