";
$myvar = 57;
echo "myvar = $myvar
";
//It is best practice to disregard use of embedded variables altogether
//and let the program editor highlighter help the programmer view the code constructs
//in a more understandable form:
$myarr[2] = 57;
echo "myvar = ".$myarr[2]."
";
echo "Using curly brackets
";
echo "myvar = {$myarr[2]}
";
//or
echo "myvar = ${myarr[2]}
";
echo "string type variable
";
$myStr="Hello World!
";
echo $myStr;
echo "string array variable
";
$myarr[0] = "cat";
$myarr[1] = "dog";
echo "myvar = $myarr[0]
";
echo "myvar = $myarr[1]
";
echo "integer type variable
";
$myStr="100";
echo $myStr."
";
echo "integer array variable
";
$myarr[2] = 57;
echo "myvar = $myarr[2]
";
echo "decimal or float type variable
";
$myStr="100.99";
echo $myStr."
";
$a = 'string 1';
$$a = 'string 2';
echo "$a ${$a}
";
echo $a.$$a."
";
//print out all super globals
//albeit not in good readable form except for scanning
//print_r($GLOBALS);
//or
//var_dump($GLOBALS);
/*
if(!empty($item_1)) {
// item amount 1
$tot_amt_1 = ($duration * $amt_1);
$tot_amt = ($duration * $tot_amt_1);
}
if(!empty($item_2)) {
// item amount 2
$tot_amt_2 = ($duration * $amt_2);
$tot_amt = $tot_amt + $tot_amt_2;
}
if(!empty($item_3)) {
// item amount 3
$tot_amt_3 = ($duration * $amt_3);
$tot_amt = $tot_amt + $tot_amt_3;
}
// in for live testing only
//print $item_1 . " - " . $item_2 . " - " . $item_3 . "
";
$tot_amt_1 = number_format($tot_amt_1, 2);
$tot_amt_2 = number_format($tot_amt_2, 2);
$tot_amt_3 = number_format($tot_amt_3, 2);
// taking only perhaps sparsely filled values
// and inputting in sequencial order
$i = 0;
$b = "";
$c = 0;
$d = "";
for ($i=1;$i<7;$i++) {
$b = strval($i);
$total = 'tot_amt_' . $b;
$$total =${$total};
if($$total>0) {
$c++;
$d = strval($c);
$item_name = 'item_name_' . $d;
$item_name2 = 'item_name_' . $b;
$$item_name =${$item_name2};
$p->add_field($item_name, $$item_name);
$item_number = 'item_number_' . $d;
$item_number2 = 'item_number_' . $b;
$$item_number =${$item_number2};
$p->add_field($item_number, $$item_number);
$item_amt = 'amount_' . $d;
$tot_amt2 = 'tot_amt_' . $b;
$$tot_amt = ${$tot_amt2};
$p->add_field($item_amt, $$tot_amt);
}
}
*/
?>