I am using Mixpanel's PHP API and want to call mp->track
.
In this case, the mp->track
is defined as an object in the mixpanel library, called via require(mixpanel.php)
.
Typically, this would work fine:
require ('mixpanel-php/lib/Mixpanel.php');
$mp = Mixpanel::getInstance("XXX");
$mp->track('Session');
However, I want to call mp->track()
from within a private function, but the following gives an object not defined
error:
require ('mixpanel-php/lib/Mixpanel.php');
$mp = Mixpanel::getInstance("XXX")
private function startSession() {
$mp->track('Session');
}