PHP Data Types
Hello friends, in this tutorial, we will learn about data types in php and it supports 8 different data types, which are classified into 3 main types.
Four scalar types:
- boolean
- integer
- float
- string
Four compound types:
- array
- object
- callable
- iterable
two special types:
- resource
- NULL
Note :
- The type of variable is not usually set by the programmer; Instead, it is determined by PHP based on the runtime in which that variable is used.
PHP Example
Edit it yourself
<!DOCTYPE html>
<html>
<body>
<?php
$var_bool = TRUE; // a boolean
$var_str = "foo"; // a string
$var_str2 = 'foo'; // a string
$var_int = 12; // an integer
$var_float = 12.12; // a float
$var_null = null; // a null
$var_array = array ("php", "java", "android", "ios"); // a array
echo gettype($var_bool); // prints out: boolean
echo gettype($var_str); // prints out: string
?>
</body>
</html>
Output of PHP comment
Edit it yourself30
Note :
- The type of variable is not usually set by the programmer; Instead, it is determined by PHP based on the runtime in which that variable is used.