-1

Could please help me understand what I am doing wrong here.

I am able to get the value of $income, but the issue is in the function ovIncome i get this error $income is undefined.

$income = $_REQUEST['income'];

//Gross Income Overview
function ovIncome() {
  //Check if Less Than or More Than
  if ($income == '0') {
    $wageVal = 'Less than € 30.984,- ';
  }
  elseif($income == '1') {
    $wageVal = 'More than € 30.984,- and same as € 61.200,-';
  }
  else {
    $wageVal = 'More than € 30.984,-';
  }
  echo "$wageVal";
}
mplungjan
  • 155,085
  • 27
  • 166
  • 222
Zain
  • 630
  • 4
  • 21

1 Answers1

1

You need to pass variable in your function as a parameter.

$income = $_REQUEST['income']; 
function ovIncome($income){//pass variable as parameter

And you will good to go.

Sample example: https://3v4l.org/dGYAj

Note: at the time of calling the function you need to pass that variable too( what I did in my code link in last line)

Anant Kumar Singh
  • 68,309
  • 10
  • 50
  • 94