Hello,
I am trying to access one class object's data member by using a constant. I was wondering if this is possible with a syntax similar to what I am using?
When I attempt to do this in the following script I get this error: Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM
class Certificate {
const BALANCE = 'cert_balance';
public function __construct() {}
}
class Ticket {
public $cert_balance = null;
public function __construct()
{
$this->cert_balance = 'not a chance';
echo $this->cert_balance."<br />";
}
}
$cert = new Certificate();
$ticket = new Ticket();
// This next code line should be equal to: $ticket->cert_balance = 'nice';
$ticket->$cert::BALANCE = 'nice!';