Trait_Stuff - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of Trait_Stuff.php
- <?php
- trait A {
- public function smallTalk() {
- echo 'You are executing smallTalk in TRAIT "A" with lowercase "a" ';
- }
- public function bigTalk() {
- echo 'You are executing BIgTalk in TRAIT "A" with UPPERCASE "A" ';
- }
- }
- trait B {
- public function smallTalk() {
- echo ' You are executing smallTalk in TRAIT "B" with lowercase "b" ';
- }
- public function bigTalk() {
- echo ' You are executing BIGTALK in TRAIT "B" with UPPERCASE "B" ';
- }
- }
- class Talker {
- use A, B {
- B::smallTalk insteadof A;
- A::bigTalk insteadof B;
- }
- }
- class Aliased_Talker {
- use A, B {
- B::smallTalk insteadof A;
- A::bigTalk insteadof B;
- B::bigTalk as talk;
- }
- }
- $talk = new Talker();
- echo $talk->smallTalk();
File Description
- Trait_Stuff
- PHP Code
- 17 Jul-2021
- 792 Bytes
You can Share it:
Latest PHP Pastes