Reputation: 5747
I have a script called ranking.php. I call this script at the top of another script (headtohead.php) as follows:
include("ranking.php");
Within the ranking script, there is a function called 'win'. In the headtohead.php script, I have a function with the following:
global $form, $database, $foottour, $ranking;
And then within the function itself:
$newHomePoints = $ranking->win($homePoints, $homescore, $awayscore, ($homeStar - $awayStar));
I am getting the error saying that the function 'win' on the line where it's called is unknown?
Upvotes: 0
Views: 1121
Reputation: 1625
is $ranking an instance of class? if not you should use $ranking = new "name of class here"(); Can you post the source of ranking.php?
Upvotes: 0
Reputation: 32148
you can try to call the method only if exists:
if (method_exists('win', $ranking)) {
$newHomePoints = $ranking->win($homePoints, $homescore, $awayscore, $homeStar - $awayStar);
}
Upvotes: 0
Reputation: 34591
$ranking->win(...)
is calling a method on an object. Is the win
function in ranking.php
actually a method within a class? If it's a standalone function then you have to call it as a standalone function.
Upvotes: 3