Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Case 1
- ```
- <?php
- interface AI {
- const FOO = 'a';
- }
- class A implements AI {
- const FOO = 'Class A';
- }
- function test(AI $obj)
- {
- echo $obj::FOO;
- }
- $obj = new A();
- test($b);
- ```
- Result:
- `Fatal error: Cannot inherit previously-inherited or override constant FOO from interface AI in [...][...] on line 6`
- Case 2
- ```
- <?php
- interface AI {
- const FOO = 'Interface';
- }
- class A implements AI {}
- class B extends A {
- const FOO = 'Class B';
- }
- function test(AI $var)
- {
- echo $var::FOO;
- }
- $obj = new B();
- test($obj);
- ```
- Result:
- `Class B`
Add Comment
Please, Sign In to add comment