I know this has been asked before and I have looked at multiple threads on why this would happen but could not understand how mine does not work as other variables defined in the same way and gathered the same way work.
class item{
var $name = "test";
var $id = 3;
function setId($newID){
global $id;
$id = $newID;
}
function getId(){
return $GLOBALS['id'];
}
function setName($newName){
global $name;
$name = $newName;
}
function getName(){
return $GLOBALS['name'];
}
}
That is a snippet of the class as it is really long but duplicate getName and setName for 5/6 more items.
$item[0]->getName();
Would return "test"
$item[0]->getId();
Returns the "Undefined index: id in link to file on line 59" which is the getId() function.
Every function other then getId() works and I have no idea why
EDIT - this question has been answered I am waiting to be able to accept an answer. $this worked for the variable to return (even though I'm still not sure why it would even though the 5 or 6 others would)