In php also know the various types of data such as programming languages in general. There are 3 basic types in php are: integer, real (floating point), and string.
Php generally have 8 types of data:
Integer data types include all integers, a large range of data php equal to range of data on the program language 'C' of about -2.147.483.648 to 2.147.483.647 on 32 bit platforms, and use 4 bytes of memory.
Php will convert integer to float point automatically if it is outside the range, integer can be expressed in decimal, octal, and hexadecimal form.
Example program:
<html>
<head>
<title>Data Type Integer</title>
</head>
<body>
Example Data Type With PHP:<br>
<p>
<?php
$num="123.400";
echo("Numbers that are used : $num<br> \n");
//data type integer
echo("Data Type Integer : $num<br> \n");
//data type string
settype($num,"String");
echo("Data Type String : $num<br> \n");
//data type double
settype($num,"Double");
echo("Data Type Double : $num<br> \n");
?>
</p>
</body>
</html>
<head>
<title>Data Type Integer</title>
</head>
<body>
Example Data Type With PHP:<br>
<p>
<?php
$num="123.400";
echo("Numbers that are used : $num<br> \n");
//data type integer
echo("Data Type Integer : $num<br> \n");
//data type string
settype($num,"String");
echo("Data Type String : $num<br> \n");
//data type double
settype($num,"Double");
echo("Data Type Double : $num<br> \n");
?>
</p>
</body>
</html>
Floating Point
Floating point (floats, double, and real) is a representation of decimal numbers. Range data type floating point equal to range data type double on 'C' language program : 1.7E308 to -1.7E308
Floating point or real can be expressed as follows:
- $a = 1.234;
- $a = 1.2e3;
- $a = 7E-10;
Boolean
In the data type boolean has only a value of true and false. Keyword true and false non-case sensitive.
There are some conditions in a boolean value that should be used, namely:
- For integer and floating point, a boolean value is false if the value is 0, and the other is true
- For Variables that have not been created / defined values are false. For the type of data object, false if no variable / function defined in it, otherwise it is true.
- For string, false if it is empty ("")
- The array data type, if the element is empty then it is false, otherwise true
0 comment:
Post a Comment