note 107852 added to language.oop5.traits
| From: | farhad dot peb at gmail dot com | Date: | Fri, 09 Mar 2012 19:29:13 +0000 |
| Subject: | note 107852 added to language.oop5.traits | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-186567@lists.php.net to get a copy of this message | ||
<?php
trait first_trait
{
function first_function()
{
echo "From First Trait";
}
}
trait second_trait
{
function first_function()
{
echo "From Second Trait";
}
}
class first_class
{
use first_trait, second_trait
{
// This class will now call the method
// first function from first_trait only
first_trait::first_function insteadof second_trait;
// first_function of second_traits can be
// accessed with second_function
second_trait::first_function as second_function;
}
}
$obj = new first_class();
// Output: From First Trait
$obj->first_function();
// Output: From Second Trait
$obj->second_function();
?>
the iranian php programmer
writer: farhad zand
farhad.peb@gmail.com
php_engineer_bk@yahoo.com
----
Server IP: 69.147.83.197
Probable Submitter: 2.185.145.71
----
Manual Page -- http://www.php.net/manual/en/language.oop5.traits.php
Edit -- https://master.php.net/note/edit/107852
Del: integrated -- https://master.php.net/note/delete/107852/integrated
Del: useless -- https://master.php.net/note/delete/107852/useless
Del: bad code -- https://master.php.net/note/delete/107852/bad+code
Del: spam -- https://master.php.net/note/delete/107852/spam
Del: non-english -- https://master.php.net/note/delete/107852/non-english
Del: in docs -- https://master.php.net/note/delete/107852/in+docs
Del: other reasons-- https://master.php.net/note/delete/107852
Reject -- https://master.php.net/note/reject/107852
Search -- https://master.php.net/manage/user-notes.php