Some of them are listed below :
PHP String :
The PHP strings can be termed as the sequence of the characters. It can be any any characters inside the quotes . The quotes may be either single ( ‘ ‘ ) or double ( ” “) .
Example :
<?php
$p = “Welcome to PHP Interview Questions !”;
$i = ‘Welcome to PHP Inerview Questions !’;
echo $p;
echo “<br/>”;
echo $i;
?>
Output as :
Welcome to PHP Interview Questions !
Welcome to PHP Interview Questions !
PHP Integer :
The PHP integer Data Types are the integer values ( non – decimal ) which lies between the -2,147,483,648 and 2,147,483,647.
General rules for the integer values .
- Integer Data Type must have at least one value .
- No decimal points are allowed.
- It can be either Positive or Negative in numbers
- It can be specified in to three formats . i.e decimal , hexadecimal and octal
<?php
$p = 6756;
print_r($p);
?>
Output as :
PHP Float (double) :
The Float or Double Data Types are the floating points values , .i.e have decimal points values or in exponential form .
Example :
<?php
$p = 67.56;
print_r($p);
?>
Output as :
67.56
Boolean :
The Boolean Data types represents two states either true or false ( 0 or 1 ).
<?php
$p = true;
$i = false;
?>
PHP Array :
The Array Data Type is the structured data which stores one or multiple types of data in single variables.
Example :
<?php
$p = array (
array(“Joe”,14,9),
array(“John”,15,10),
array(“Hari”,16,11),
array(“Lakhan”,17,12)
);
print_r($p);
?>
Output as :
Array ( [0] => Array ( [0] => Joe [1] => 14 [2] => 9 ) [1] => Array ( [0] => John [1] => 15 [2] => 10 ) [2] => Array ( [0] => Hari [1] => 16 [2] => 11 ) [3] => Array ( [0] => Lakhan [1] => 17 [2] => 12 ) )
PHP Object :
The PHP Object can be termed as the instance of the class defined by the programmer that encapsulate both types ( variable & functions ) data which is defined in the specific class. The object must be explicitly declared .
Example :
<?php
class piq {
public $pival=’PHP Interview Questions’;
function pi() {
return $this->pival;
}
}
// creating an object for piq
$pq = new piq();
// call object properties
echo $pq->pi();
?>
Output as :
PHP Interview Questions
PHP NULL :
NULL is the specific type of data types that have single specific data : NULL.
Simple , we can say that the null data type are such which don’t have any assignment to variables .
Example :
<?php
$p = “Welcome to PHP Inerview Questions !”;
$p = null;
var_dump($x);
?>
Output as :
NULL
PHP Resource :
The Resources are the special types Data Type or variables that holds the external references in PHP . For Example :
Database connection in PHP