Hi everyone, I'm new to php and am in need of a little help in figuring out why my variable is not being assigned any value.
So I have a global file that has my global variable that main.php uses.
global.php:
<?php
$gYearToBeginIncomePayments = 6;
// Base Contract Parameters ( Taken from the 'Client Inputs' Tab/Sheet. )
$gPremiumBonusPercentage = 0.05;
$gGmvRate = 0.01;
$gCurrentCAP = 0.035;
$gCurrentParticipationRate = 0.20;
$gMinNonForefeitureRate = 0.01;
$gBenefitBasePremiumPercentage = 1.10;
$gPremium = 10000;
// Arrays
$gEndOfYear = [];
$gAgeEOY = [];
$gPremium = [];
$gBonus = [];
$gAccountValueBOY = [];
$gAnnualWithdrawalsBOY = [];
$gInterestCredited = [];
$gRiderCharge = [];
$gAccountValueEOY = [];
$gCashValueEOY = [];
$gCreditedInterestPct = [];
$gBenefitBaseBOY = [];
$gIncomeBenefit = [];
$gInterestCredited = [];
$gBenefitBaseEOY = [];
$gGuaranteedMinimumValue = [];
?>
main.php
<?php
//global variables
$gIssueAge = $_POST['txtIssueAge'];
$SinglePremium = $_POST['txtSinglePremiumMarket'];
$SinglePremium = preg_replace('/[\$,]/', '', $SinglePremium);
$gNumberOfRows=$_POST['txtYearsToPrintMarket'];
$LastAgeToPrint = $_POST['txtLastAgeToPrintMarket'];
//calculations
for($i = 0; $i < $gNumberOfRows; $i++) $gAgeEOY [$i] = $i + $gIssueAge;
$gPremium[0] = $SinglePremium;
for($i = 1; $i < $gNumberOfRows; $i++) $gPremium[$i] = 0;
$gBonus[0] = $gPremium[0] * $gPremiumBonusPercentage;
$gAccountValueBOY[0] = $gPremium[0] + $gBonus[0];
for($i = 0; $i < $gYearToBeginIncomePayments - 1; $i++) $gAnnualWithdrawalsBOY[$i] = 0;
$gBenefitBaseBOY[0] = ($gPremium[0] * $gBenefitBasePremiumPercentage) * $RiderSelected;
$gAnnualWithdrawalsBOY[0] = if($gAgeEOY < $gYearToBeginIncomePayments[0], 0, if($gAgeEOY[0] = $gYearToBeginIncomePayments[0], 0.0*$gBenefitBaseBOY[0], max($gIncomeBenefit[0],0.0*$gBenefitBaseBOY[0]) ));
for($i = 0; $i < $gNumberOfRows; $i++) {
$gAccountValueEOY[$i] = max(0, ( $gAccountValueBOY[$i] - $gAnnualWithdrawalsBOY[$i] + $gInterestCreditedColG{$i} - $gRiderCharge{$i} ));
$gAccountValueBOY[$i] = $gAccountValueEOY[$i - 1];
$gInterestCreditedColG[$i] = max(0, (( $gAccountValueBOY[$i] - $gAnnualWithdrawalsBOY[$i] ) * $gCreditedInterestPct[$i]) );
}
for($i = 0; $i < $gNumberOfRows; $i++) {
$GuaranteedFirstValue = (($gPremium[0] * 0.875) * (1 + $gGmvRate)) - 50;
if ($i == 1) {
$GuaranteedMinValue = $GuaranteedFirstValue[$i];
}
else {
$gGuaranteedMinValue = max(0, ($GuaranteedFirstValue - 0) * (1 + $gPremiumBonusPercentage)) - 50;
}
}
?>
Issues:
1. my formulas inside the loop don't show any values, such as the $Premium[0].
2. when I try to run var_dump, I don't see anything.
3. I am using dompdf to convert html to pdf by the way.
4. all the formulas I am trying to accomplish is from a excel sheet which I am trying to calculate inside php, I don't know if this is even possible. Perhaps this is why I don't get any values for the fields??
Any help would be great.
Thanks