note 109448 modified in language.oop5.traits by danbrown

From: Date: Fri, 20 Jul 2012 15:30:11 +0000
Subject: note 109448 modified in language.oop5.traits by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-189339@lists.php.net to get a copy of this message
Not very obvious but trait methods can be called as if they were defined as static methods in a regular class&#13;&#10;&#13;&#10;&#60;?php&#13;&#10;trait Foo {&#13;&#10;&#9;function bar() {&#13;&#10;&#9;&#9;return &#39;baz&#39;;&#13;&#10;&#9;}&#13;&#10;}&#13;&#10;&#13;&#10;echo Foo::bar(),&#34;\\n&#34;;&#13;&#10;?&#62; --was-- Not very obvious but trait methods can be called as if they were defined as static methods in a regular class <?php trait Foo { function bar() { return 'baz'; } } echo Foo::bar(),"\n"; http://php.net/manual/en/language.oop5.traits.php

« previous php.notes (#189339) next »