Method to static method

Create class A has not method full

class A{

}

Create class B has method full

class B{
   public function full(){
      echo "success";
   }
}

How do?

A::full();
// success

Upvotes: 0

Views: 20

Answers (1)

Saumini Navaratnam
Saumini Navaratnam

Reputation: 8850

First class A should extend class B so the method full will available in class A.

class A extends B
{

}

Second you have to use static keyword in method full.

public static function full()
{
    ...
}

References :

Inheritance

Static

Upvotes: 1

Related Questions