PHP Variables

A variable is a container to store information like numbers, characters, strings, etc. In PHP variable is declared using the $ sign followed by the variable name. PHP is a loosely typed language so we don’t need to declare the data type of the variable. It automatically assigns the data type to a variable based on the assigned value.

Naming Convention.

Creating Variables.

<?php  
$lang    = "This is PHP";  
$number  = 100;  
$pie     = 3.14;  
echo "Language is:". $lang. "<br>";  
echo "Number is: $number <br/>";  
echo "Pie =   $pie";  
?>

Output.

Language is:This is PHP
Number is: 100 
Pie = 3.14

 

Install PHP       PHP Syntax

Exit mobile version