Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling a method within an other method

Status
Not open for further replies.

Cambridge10

Programmer
May 5, 2008
18
NL
I've just started to work with Php 5 OO.

function totalVehicleWeight calculates the total weight of the vehicle. It return that to the screen of the user.
function diffFrontRear calculates the diff of the front and rear but it's also need the input of function totalVehicleWeight.
How should I call function totalVehicleWeight within function diffFrontRear?

The code:

<?php

class Calculate
{
private $lfweight;
private $rfweight;
private $lrweight;
private $rrweight;
private $result;

function totalVehicleWeight($lfweight,$rfweight,$lrweight,$rrweight)
{
return $this->result=($lfweight+$rfweight+$lrweight+$rrweight);
}

function diffFrontRear($lfweight,$rfweight)
{
return $this->result=(($lfweight+$rfweight)/(result of function totalVehicleWeight/100));
}

?>
 
Hi

Like this ?
Code:
function diffFrontRear($lfweight,$rfweight)
{
  return $this->result=(($lfweight+$rfweight)/($this->totalVehicleWeight($lfweight,$rfweight,$lrweight,$rrweight)/100));
}

Feherke.
 
Just out of curiosity, is this the entire class, or did you just give us the parts we needed?

Scott Prelewicz
Web Developer
COMAND Solutions
 
Hi,

Only the parts needed.

Thank you feherke. It works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top