How do classes do this?
Class Main { $this->a = new A(); $this->b = new B(); $this->c = new C(); $this->b->doTranslate($this->a->saySomething()); }
And how do the traits do it?
Class Main { use A; use B; use C; $this->doTranslate($this->saySomething()); }
I have little knowledge of features, but looking at new examples of PHP 5.4 features, they seem to only help in one case. A class only be extended once to use $this together, but we can use multiple traits.
Question 1: Is this the only advantage of using traits over base classes?
Question 2: If trait A, B, and C all have a function called example() when I try $this->example(); how will PHP determine which attribute will be used? What will happen?
Also, instead of writing a wall of text; just provide me an example of a short code with a short message that I can look at and take over. I am not familiar with the features and do not know what they really are.
source share