I'm trying to call a function getBMR() which is in another file (user.php) with the following code and I'm getting an error:
Using $this when not in object context )..
variables are set in the process.php file that I am calling the function in
$a =$_POST["example"];
Here is the code
echo $this->getBMR($a,$b,$c,$d,$e,$f);
Thanks, any help would be great.
class user {
public function getBMR()
{
switch ($this->gender){
case 'Female':
$gender= 655 + (9.6 * $userWeight ) + (1.8 * $userHeight) - (4.7 * $userAge);
echo "<p>Your estimated daily metabolic rate is $gender </p>";
echo "<p>This means that you need rouhgly $gender calories a day to maintain your current weight.</p>";
break;
case 'Male':
$gender=66 + (13.7 *$userWeight) + (5 * $heuserHeightight) - (6.8 * $userAge);
echo "<p>Your estimated daily metabolic rate is $gender </p>";
echo "<p>This means that you need rouhgly $gender calories a day to maintain your current weight.</p>";
}
}
require(user.php);at the top ofprocess.phpgetBMR(), the way you instantiate it (e.g.$obj = new someClass();) and how you're trying to use methodgetMBR()