PHP

Variables: (PHP Tutorials:part-2)

Written by Saiful Islam

What are Variables ?

Variables are such kind of carrier which carries various values of a program. In a program those values can vary in terms of different conditions (addition, subtraction, multiplication, division, etc.). We can put different values through those variables and use that wherever we want (in a program).

You can put both numbers and texts through variables. Such as, if the variable is x and the value of x is Welcome to Tech-info24.com (as a text) then we can carry this text by the variable x. And if we keep the number, 10 (as a numeric value) into the variable then we can easily use the number in the program for various purposes like summation, substruction, multiplication, division etc.

Variables in PHP:

For both numeric values and texts we have to use $ sign before the variable and semicolon sign at the last. But only for PHP we have to put the text within “ ”.

Example:

1. For textual value:

 

Input

Output

Welcome to Tech-info24.com

 

2. For numeric value:

 

Input Output
  100

 

3. For both textual and numeric value:

Input Output
  How many programs have you written?15

 

 

 

About the author

Saiful Islam

Leave a Comment