PHP - Variables and Data types

What is a Variable?

Variables are used to store values into the system's memory. Variables allows to perform set of actions and can be re-use within the code. You can change the out put of the program by changing the variable values rather changing the script.

Data Types

String    : used for character values such as sentences, names stc
Integer  : used to store numeric values of whole numbers
Float      : used to store numeric values of real numbers
Boolean: used to store either true or false or 1 or 0
Object   : used to store collection of values (data) or methods

Important: PHP is loosely typed language, that means your script determines the data type of the variable. 

Ex: 
$val = "PHP Programming" // This is considering as String Value
$val = 50 // This is considering as Integer Value

$val = "100" //This is considering as String value
$val =  $val * 5 // This is considering as Integer value
$val = $val * 1.25 //This is considering as float value

1 comment:

  1. Nice content presentation! Thanks for putting the efforts on gathering useful content and sharing here. You can find more Programming languages related question and answers in the below forum.

    Programming language question and answers

    ReplyDelete