0

Somehow my constructor doesn`t seem to work properly:

private $matchId;
private $region;
private $date;
private $wAdc;
private $wSupp;
private $lAdc;
private $lSupp;
private $summoners;

public function _construct($matchId, $region, $date) {
    $this->matchId = $matchId;
    $this->region = $region;
    $this->date = $date;
    $this->summoners = array();
    $this->wAdc = null;
    $this->wSupp = null;
    $this->lAdc = null;
    $this->lSupp = null;
}

public function getMatchId() {
    return $this->matchId;
}

And here the object creation:

$matchObj = new match($matchId, $region, $created);
$matches[] = $matchObj;
echo "a: ". $matchId . " ";
echo "b: ". $matchObj->getMatchId() . " ";

And here the output I get when I run the script in my browser:

a: 1936074952 b: 

So the object variable doesn`t seem to get set properly. Could anybody help me out?

2 Answers 2

4

You forgot a underscore

It should be public function __construct()

Sign up to request clarification or add additional context in comments.

3 Comments

You mean an underscore ;)
@Machavity True I forgot the english translation.
Thanks, that was the problem!
1

There is an error in your constructor, try this:

public function __construct($matchId, $region, $date) {...}

1 Comment

Thanks, that was the problem!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.