Is it possible to define a PHP class property and assign the value dynamically using a property within the same class? Something like:
class user { public $firstname = "jing"; public $lastname = "ping"; public $balance = 10; public $newCredit = 5; public $fullname = $this->firstname.' '.$this->lastname; public $totalBal = $this->balance+$this->newCredit; function login() { //some method goes here! } } Yields:
Parse error: syntax error, unexpected '$this' (T_VARIABLE) on line 6
Is anything wrong in the above code? If so, please guide me and if it is not possible then what is a good way to accomplish this?