• 追加された行はこの色です。
  • 削除された行はこの色です。
* 複数のインターフェイスを実装する際のメソッド名衝突 [#q3f3b7c8]



 <?php
 interface Interface1 {
     public function foo();
     public function bar();
 }
 interface Interface2 {
     public function bar();
 }
 class Class1 implements Interface1,Interface2 {
     public function foo() {}
     public function bar() {}
 }

これを実行すると↓。

 PHP Fatal error:  Can't inherit abstract function Interface2::bar() (previously declared abstract in Interface1) 
 in /home/taro/tmp/Class1.php on line 9

ちなみにJavaだとOK↓。
 interface Interface1 {
     void foo();
     void bar();
 }
 interface Interface2 {
     void bar();
 }
 public class Class1 implements Interface1, Interface2 {
   public static void main( String args[] ) { }
   public void foo() { }
   public void bar() { }
 }


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS