I have this class:
<?php
class Test {
private $_ID;
private $_NAME;
private $_AGE;
public function setID() { $this->_ID++; }
public function getID() { return $this->_ID; }
public function setNAME($element) { $this->_NAME = $element; }
public function getNAME() { return $this->_NAME; }
public function setAGE($element) { $this->_AGE = $element; }
public function getAGE() { return $this->_AGE; }
public function addUser($name, $age) {
Test::setID();
Test::setNAME($name);
Test::setAGE($age);
echo "OK";
}
}
?>
I want to create objects of this class, and assign the data with the function addUser like this:
$test = new Test();
$test:: addUser("Peter", "12"); but I have errors.
I have this errors:
Strict Standards: Non-static method Test::addUser() should not be called statically in /var/www/public/testManu.php on line 13
Strict Standards: Non-static method Test::setID() should not be called statically in /var/www/public/class/Test.php on line 18
Fatal error: Using $this when not in object context in /var/www/public/class/Test.php on line 8
I have problems with variable scope. Could somebody tell me what it is my problem????