I am pretty new to PHP and I have come accross a problem.
I have two files, index.php and test.php:
class Test {
        private $name;
        public function __construct($name) {
            $this->name = $name;
        }
        public final function getName() {
            return $this->name;
        }
      }
And
class Index {
        private $testVar;
        public function test() {
            return $this->testVar = new Test('test');
        }
        public function print() {
        echo $this->testVar->getName();
        }
      }
In Index.php, I would like to print the accessable function of Test.php, but that does not work like this. I get the following error:
Fatal error: Call to a member function getName() on a non-object in /home/Index.php on line 10
Line 10 being: echo $this->testVar->getName();
What am I doing wrong?
 
    