I am trying to call a method from a different class in a different file. However, When I run the code i get the following error:
Fatal error: Call to undefined function getFxRate() in fxCalc.php
Here is the code I am trying to build:
fxCalc.php
//call fxDataModel class
require_once('fxDataModel.php');
$fxRate = getFxRate($inputCurrency, $outputCurrency);
$txtOutput = $txtInput * $fxRate;
fxDataModel.php
public static function getFxRate($inputCurrency, $outputCurrency)
{
$fxRate = $currencies[$inputCurrency][$outputCurrency];
return $fxRate;
}
Any help would be appreciated.
getFxRate()is a static method of another class. You need to call it asOtherClassName::getFxRate($inputCurrency, $outputCurrency)staticmethods are scoped and called...