0

Is it possible to inherit a trait from another trait?

For example:

class A {
     use AB;
     use AC;
}

trait AB {
public function DoSome1() {
     echo 'hello1';

     // I want to echo out AC here
     // Will not work due to error: class declarations cannot be nested
     class NewClass {
          use AC;
     }
     $Display = new NewClass;

     // HOW TO DISPLAY LIKE THIS
     $Display->DoSome2();
}

trait AC {
public function DoSome2() {
     echo 'hello2';
}

$Display = new A;

// Outputs normal hello1
$Display->AB();

I want to include trait AC inside of AB. Is that possible?

0 Answers0