Please help me to understand this:
1 <?php
2 class test{
3 private $a = "a";
4 private $b = $a."b";
5
6 function __construct(){
7 echo $this->b;
8 }
9 }
I get Constant expression contains invalid operations on line 4
Why? I tried also with $this->a but it also do not work.
Please explain it to me.
Update
For some strange reason this works
class test{
private const a = "a";
private $b = self::a."b";
function __construct(){
echo $this->b;
}
}
I can remember now that it does not work. But can someone please explain it to me.