How to add template in codeigniter |how to create template in codeigniter| template in codeigniter 4
Variable Program
Understanding Variable in Program
Adding two integer
<?php //We need not declare data type of a variable. //PHP automatically set data type of its variable. $number1 = 12; //this is integer type variable $number2 = 14.5; //this is float type variable. //Here .(dot) is used to join two string. echo 'Addition of two variable is '.($number1+$number2); ?>
Output : Addition of two variable is 26.5
Handle String
<?php //this variable type is set as string type. $string1 = 'Hello'; $string2 = 'World'; echo $string1." ".$string2; ?>
Output : Hello World
Understanding of Dynamic Variable
<?php $name = 'India'; //This variable contain the text "India" $name1 = 'name'; //This variable contain the text "name" echo $name1.'<br>'; // The output will be : name //The output will be : India, //because double $(dollar) contain the value of 'name' variable echo $$name1; ?>
Another Example of dynamic variable
<?php $number1 = 1000; $number2 = 2000; $number3 = 3000; echo 'the value of number3 is '.$number3.'<br>'; // Output: the value of number3 is 3000 $number3 = 'number2'; echo 'the value of number2 is '.$$number3.'<br>'; // Output: the value of number2 is 2000 $number3 = 'number1'; echo 'the value of number1 is '.$$number3.'<br>'; // Output: the value of number1 is 1000 ?>
Related posts