4. const ONE = 1;
const TWO = ONE * 2;
echo ONE; // 1
echo TWO; // 2
5. class C {
const THREE = TWO + 1;
const ONE_THIRD = ONE / self::THREE;
const SENTENCE = 'The value of THREE is
'.self::THREE;
public function f($a = ONE + self::THREE) {
return $a;
}
}
echo (new C)->f(); //4
echo C::SENTENCE; //The value of THREE is 3
17. class C {
private $prop;
public function __construct($val) {
$this->prop = $val;
}
public function __debugInfo() {
return [
'propSquared' => $this->prop ** 2
];
}
}
31. class A {
function f() { echo
get_class($this); }
}
class B {
function f() { A::f(); }
}
(new B)->f();
//output
PHP Deprecated: Non-static method A::f() should not be called
statically, assuming $this from incompatible context in ...