Last active
October 9, 2015 18:34
-
-
Save dunglas/691dd6f2e20c1bb7b966 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
trait T | |
{ | |
public function __construct() | |
{ | |
echo "Trait contructor"; | |
} | |
} | |
class A | |
{ | |
public function __construct() | |
{ | |
echo 'Parent constructor'; | |
} | |
} | |
class B extends A | |
{ | |
use T; | |
} | |
new B(); | |
// Output: | |
// Trait constructor | |
trait T2 | |
{ | |
public function __construct() | |
{ | |
parent::__construct(); | |
echo "Trait contructor"; | |
} | |
} | |
class A2 | |
{ | |
public function __construct() | |
{ | |
echo 'Parent constructor'; | |
} | |
} | |
class B2 extends A2 | |
{ | |
use T; | |
} | |
new B2(); | |
// Output: | |
// Parent constructor | |
// Trait constructor |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment