PHP Variables

අපි දන්නවා variable එකක් use කරන්නේ text, string, numbers එහෙමත් නැත්තම් array එකක් store කරගන්න කියලා. යම් value එකක් variable එකකට assign කලාම එය නැවත නැවත බාවිතා කරගන්න පුළුවන්. PHPවල ඕනෑම variable එකක් පටන්ගන්නේ $ ලකුණෙන්. $ ලකුණෙන් පසුව අකුරක් හෝ _ (underscore) වලින් තමා variable එකේ නම පටන් ගන්න ඕනේ. තවත් විශේෂ දෙයක් තමයි අපි variable එකක් assign කරනකොට එකේ data type එක php වලින්ම convert කරගන්නවා. දැන් අපි example කීපයක් බලමු.

Example 01

<?php
$age=23;
$name='Vidura';
echo "Hi, $name You are $age years old";
?>

Output එක එන්නේ මෙහෙමයි 

Example 02

<?php
$age=23;
$name='Vidura';
$add=5;
$fage=$age+$add;
echo "Hi, $name You are $fage years old in five years";

?>

Output: