-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
  • 169,008
  • 28
  • 173
  • 236
Zain
  • 662
  • 9
  • 26

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)

Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98