June 24, 2021

TriStudy

TriStudy Provide Free Online Tutorials about Programming languages,Digital Marketing, web designing, online earning, web hosting, WordPress etc

Data Types of PHP.

php data types

PHP is an approximately composed language; it doesn’t have express characterized information types. PHP decides the information types by investigating the qualities of information provided. PHP verifiably bolsters the accompanying information types

PHP supports the following data types:

Whole number – entire numbers for example – 3, 0, 69. The most extreme estimation of a number is stage subordinate. On a 32 piece machine, it’s typically around 2 billion. 64 piece machines as a rule have bigger esteems. The consistent PHP_INT_MAX is utilized to decide the most extreme worth.

php learn
  • String
  • Integer
  • Float (floating point numbers – also called double)
  • Boolean
  • Array
  • Object
  • NULL
  • Resource

1.Alphanumeric characters are classified as strings
2.Whole numbers are classified integers
3.Numbers with decimal points are classified as floating points.
4.True or false values are classified as Boolean.

<?php
echo PHP_INT_MAX;
?>

output;

922337200368547758007

Drifting point number – decimal numbers for example 3.14. they are otherwise called twofold or genuine numbers. The most extreme estimation of a buoy is stage subordinate. Gliding point numbers are bigger than whole numbers.

Character string – for example Hi World

Boolean – for example Genuine or bogus.

Before we go into more subtleties examining PHP information types, allows first talk about factors.

PHP Variable

A variable is a name given to a memory area that stores information at runtime ,The extent of a variable decides its perceivability ,A Php worldwide variable is available to every one of the contents in an application ,A neighborhood variable is just open to the content that it was characterized in ,Think about a variable as a glass containing water. You can include water into the glass, drink every last bit of it, top off it again and so forth.

The equivalent applies for factors. Factors are utilized to store information and give put away information when required. Much the same as in other programming dialects, PHP underpins factors as well. We should now take a gander at the principles pursued when making factors in PHP.

<?php
$my_var = 1;
echo $my_var;
?>

output: 1

Floating point number.

<?php
$my_var = 3.14;
echo $my_var;
?>

output: 3.14

character string.

<?php
$my_var ="Tristudy Is Best ";
echo $my_var;
?>

output: Tristudy Is Best

We have quite recently characterized a variable named x with the number a variable named y with the string “foo” and a variable name z with the boolean worth True. When they are characterized, we can utilize them in the code. PHP has numerous sorts of factors, however the most essential variable sorts are number (entire numbers), drift (genuine numbers), strings, and booleans. PHP additionally has exhibits and articles which we will clarify in different instructional exercises. Factors can likewise be set to NULL, which implies that the factors exist, yet don’t contain any worth.

for eg : variable contains whole number, buoy, and string esteem

<?php
 
$num=100;
 
$fnum=100.0;
 
$str="Hello";

var_dump($num,$fnum,$str);

?>

output: int(100) float(100) string(5) “Hello”

<?php
 
$str="Welcome user";
 
$str1='how r you?';
 
$str2="@";
 
var_dump($str);

var_dump($str1);

var_dump($str2);

?>

output: string(12) “Welcome user” string(10) “how r you?” string(1) “@”

Information types determine the estimate and sort of qualities that can be put away. Variable shouldn’t be proclaimed ITS DATA TYPE enhancing it. PHP is a Loosely Typed Language so here no compelling reason to characterize information type. To check esteem, information type and size use var_dump( ) work .