Scalar datatypes php

data type in php
Scalar data types : –   this data type is  further divided into  four different types .

  1. Boolean
  2. Integer
  3. Float
  4. String
Boolean

This data type can represent either true or false . In PHP value is 1 and value of false doesn’t any value.
is_bool : Using this function , we can check input variable is boolean or not.
(bool) var  OR  (boolean) var     using this function , we  convert variable into boolean variable.

Integer

This data type can store numeric value
is_int  OR  is_integer    it is used to  cheak input variable is integer or not .
(int)var ))OR  (integer) var  OR intval(var)    Using this function , we convert variable into integer variable.

Float

this  data type  can store decimal values .

is_float ()  this function cheacks input variuable  is float or not.
(float)var   Converts a variable into floating point number.

String

It is a collection of character.
In PHP , we can declar string in  three ways.

  1.    By using single quotations
  2.    By using double quotations
  3.    By using heredoc syntax

NOTE  Variable in double quotations returns value of variables.

Heredoc   PHP suports heredoc  syntax to avoid the conflicts what we getting with single and double quotations.

Continue reading