<?php
trait A {
protected static $_a;
public static function setA($a)
{
static::$_a = $a;
}
public static function getA()
{
return static::$_a;
}
}
A::setA('AAAA');
class B {
use A;
public function __construct()
{
var_dump(static::$_a);
}
}
//A::setA('AAAA');
new B();
B::setA('BBBB');
new B();
echo A::getA();
echo B::getA();
Deprecated: Calling static trait method A::setA is deprecated, it should only be called on a class using the trait in /in/bAOYX on line 17
Deprecated: Accessing static trait property A::$_a is deprecated, it should only be accessed on a class using the trait in /in/bAOYX on line 8
NULL
string(4) "BBBB"
Deprecated: Calling static trait method A::getA is deprecated, it should only be called on a class using the trait in /in/bAOYX on line 37
Deprecated: Accessing static trait property A::$_a is deprecated, it should only be accessed on a class using the trait in /in/bAOYX on line 13
AAAABBBB