<?php trait TraitA{ public function sayHello(){ echo 'Hello world!'; } } class ClassA{ use TraitA{ sayHello as protected;} } class ClassB{ use TraitA{ sayHello as private;} } $objA = new ClassA(); // $objA->sayHello(); // Fatal error: Call to protected method ClassA::sayHello() from context $objB = new ClassB(); // $objB->sayHello(); Fatal error: Call to private method ClassB::sayHello
You have javascript disabled. You will not be able to edit any code.