Exemple #1
0
<?php

trait T
{
    function F(&$a, $b = "default")
    {
        $a .= " = " . $b;
    }
}
class C
{
    use T;
}
$o = new C();
$x = "value";
$o->F($x);
echo $x;
echo "\n";
$y = "zero";
$o->F($y, "0");
echo $y;
?>

Exemple #2
0
<?php

trait T
{
    public static function F()
    {
        echo "Hello from static function!\n";
    }
}
class C
{
    use T;
}
C::F();