PHP | PHPSTORM | KEYWORDS |TYPES OF DATATYPES

PHP KEYWORDS 

PHP | PHPSTORM | KEYWORDS |TYPES OF DATATYPES



There are 24 keywords in php. php keywords are case sensetive. the following php keywords are

  1. break
  2. case
  3. catch
  4. do 
  5. class
  6. function
  7. elseif
  8. public
  9. throw
  10. for
  11. endfor
  12. extends
  13. if
  14. new
  15. static
  16. try
  17. exception
  18. while
  19. endwhile
  20. exit
  21. else
  22. or
  23. switch
  24. var 

PHP DATATYPES

PHP | PHPSTORM | KEYWORDS |TYPES OF DATATYPES

there are 8 datatype in php as follow
  1. integer
  2. float
  3. string
  4. boolean
  5. null
  6. resource
  7. array
  8. object 

  • SCALAR DATATYPE integer, float, string, boolean.                         
  • SPECIAL DATATYPE - null, resource.                                    
  • COMPOUND DATATYPE - array,object.

1. INTEGER 
      
   
     An integer data type is a non decimalnumber  for e.g-

<?php
$a=10;
var_dump($a);
?>

output - int 10


2. FLOAT

Float ia a number with decimal point for e.g-

<?php
$a=10.5;
var_dump($a);
?>

output - float 10.5


3. STRING

A string is a sequence of character. A string can be any type inside codes either double code or single code. for e.g-


<?php

$a='hello';

var_dump($a);
?>

output - string hello

                                                    OR

<?php
$a="hello"
var_dump($a);
?>

output - string hello

there are four type of string in php follow as-

1.single qouted string

In this string the string enclosed with single code.

<?php
$a='hello';
var_dump($a);
?>

2.double qouted string

in this string the string enclosed with double code.

<?php
$a="hello";
var_dump($a);
?>

3.heredoc

In this string the string use multiline string with double code.

<?php
$a="hello how are you i am fine what about you";
var_dump($a);
?>

4.nowdoc 

In this string the string use multiline string with single code.


<?php

$a='hello how are you i am fine what about you';

var_dump($a);
?>

4. BOOLEAN

A boolean represent two possible states either true or false. for eg-

<?php
$a=10;
if($a%2==0)
{
true;
}
else
{
false;
}
?>

output - true


5. NULL

Null is a special datatype which can have only one values that is null. and if a variable is created without the value it is automatically assigned a value null. for e.g-

<?php
$a=Null;
var_dump($a);
?>

output - Null

                                                  OR

<?php
$a="";
var_dump($a);
?>

output - Null


6. RESOURCE

A resource is a not  actual data type it is use for storing a refference to a function.


7. ARRAY

An array stores multiple values in one single variable. for eg-


<?php

$cars=Array("bmw","alto","swift","audi";

var_dump($cars);
?>

output - array([0]=>bmw,[1]=>alto,[2]=>swift,[3]=>audi)

In php there are two types of array -

1. Index array

In index array only have values.

<?php
$cars=Array("bmw","alto","swift","audi";
var_dump($cars);
?>

output - array([0]=>bmw,[1]=>alto,[2]=>swift,[3]=>audi)

2.Associative arry

In associative array have key and values.

<?php
$cars=array([0]=>bmw,[1]=>alto,[2]=>swift,[3]=>audi)
var_dump($cars);
?>

output - array([0]=>bmw,[1]=>alto,[2]=>swift,[3]=>audi)


8. OBJECT

object is a real word entity. it is blue print of class. it is used access to the class. for eg-

<?php
class demo
{
Function Display()
{
$a='hello';
var_dump($a);
}
}
$d=new demo();
$d=>display() ;
?>

Post a Comment

0 Comments