looking for some solutions? You are welcome.

SOLVED: Call top level class function in php

Atul:

I have a scenario, in that, I have three separate classes file A.php, B.php, C.php.

A.php is independent file having some functions and 'B' extends 'A', and 'C' extendes 'B'.

Here In 'C.php' file i am able to access function of 'B.php' but not of 'A.php'.

Here is my structure -

In A.php -

class A {
    public function testA(){
        echo "AA";
    }
}

In B.php -

class B extends A{
    public function testB(){
        echo "BB";
    }
}

In C.php -

class C extends B{
    //Here i am able to call class B's function like 
    public function testC(){
        $this->testB();
    }

    //but not able to call Class A's function 
    public function testC1(){
        $this->testA();  // Here its giving error
    }
}

Please let me know is it the right way to do it. How can I access 'A.php's' function in 'C.php'

Regards



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
Share:

No comments:

Recent