php tutorial - PHP Data Types - php programming - learn php - php code - php script



  • The main approach of data types is to store the data in the PHP program by using a variable.
  • PHP supports the following data types:
php - php 7 - php tutorial - php framework tutorial - php examples - php sample code - php basics - php web development - php components - php project - php technology  - learn php - php online - php programming - php program - php code - html code - embedded php in html - php-datatype

Scalar types :

  • boolean
  • integer
  • float
  • string
php - php 7 - php tutorial - php framework tutorial - php examples - php sample code - php basics - php web development - php components - php project - php technology  - learn php - php online - php programming - php program - php code - html code - embedded php in html - web server  - php syntax - php function - variable types

Compound types :

  • array
  • object

Special types :

  • resources
  • NULL

Boolean values :

  • Boolean is the simplest data type. It’s like a switch that has only two states ON means true(1) and OFF means false(0).

Syntax :

$x = true;
$y = false;
click below button to copy the code. php tutorial - team

Integers :

  • Integer means numeric data types. A whole number with no fractional & decimal component will be there.
  • Integer may be lesser than or greater than or sometimes equals to zero.

php tutorials Syntax :

<?php
    $x = integer;
    var_dump($x);
?>
click below button to copy the code. php tutorial - team

Floating point numbers :

  • A floating point number is a number with a decimal point or a number in exponential form.

php programming Syntax :

<?php
    $x = float;
    var_dump($x);
?>
click below button to copy the code. php tutorial - team

Strings :

  • A string is series of characters, where a character is the same as a byte.
  • This means that PHP only supports a 256-character set, and hence does not offer native Unicode support.

php programming Syntax :

<?php
    $x = “String Statement”;
?>
click below button to copy the code. php tutorial - team

Array :

  • An array stores several values in one single variable.

php programming Syntax :

<?php
    $arrayname = array("array1","array2","array3");
?>
click below button to copy the code. php tutorial - team

Object :

  • An object is a data type which stores data and information on how to process that data.

Resources :

  • The resources are special variables that holds the references to resources which is external to PHP such as database connections.

NULL :

  • The NULL is defined as a special variable. Mostly, the data type which means non existent or not known or else empty.

php programming Syntax :

<?php
    $my_var = NULL;
?>
click below button to copy the code. php tutorial - team



Related Searches to php data types