2016-06-15 13 views

答えて

1

あなたはすべての時間をオブジェクトを返す必要があります。それはfluent interfaceと呼ばれています。それは自己または他のオブジェクトにすることができます。

<php 
class A 
{ 
    public function first() 
    { 
     // Do something 

     return $this; 
    } 
    public function callSecond() 
    { 
     // Do somewthing else 

     return $this; 
    } 
} 

$a = (new A())->first()->callSecond(); 
+0

これのために今何か? http://stackoverflow.com/questions/37823434/php-how-can-close-the-html-tags-from-this-array –

1
<?php 
    class OtherClass{ 
     public function callSecond(){ 
      echo 'Second Called'; 
     } 
    } 

    class MyClass{ 
     public function first(){ 
      return new OtherClass(); 
     } 
    } 

    $myClass = new MyClass(); 
    $myClass->first()->callSecond(); 
?> 
+0

多くのおかげで私の友人:) –

+0

問題ありませんサー、問題はない – ksealey

+0

あなた、今何かを持つオブジェクトである第一> $ myClass-'の結果を意味し、このため? http://stackoverflow.com/questions/37823434/php-how-can-close-the-html-tags-from-this-array –

関連する問題