The below code is used with queries. console_log is a function that prints PHP output to the console output, I took it from the internet. However, I don't think these are the problems.
class Holder {
public $name = "";
public $uid = 0;
public $wrs = 0;
}
function getWRForMapRun($mapid, $runid) {
...
$user = new Holder();
...
$user->$uid = $uid;
$user->$name = $name;
console_log("uid " . $uid . " name " . $name); // correct
return $user;
}
function returnWRersMaps() {
...
$userr = new Holder();
console_log("mapid " . $row['mapid'] . " runid " . $row['runid']); // valid values
$userr = getWRForMapRun($row['mapid'], $row['runid']);
console_log("id " . $userr->$uid . " name ". $userr->$name); // empty
}
The problem with the code above is that at the last console log values are empty. It prints something like this: id name . Not even 0, as one would expect if there was a typical bug.
I checked and values match when getWRForMapRun is called. (called in the correct order, and that console log provides the correct information.
It is among my first times using PHP, so it might be the object oriented part that's causing this.
Any clues to what needs to be done to receive the correct values?
EDIT: Using PHP 7
EDIT2: Edited first console_log to reflect reality - sorry!