I try to access a constant in a class:
file1.php
[...]
define('SUBDOMAIN','name');
require_once 'file2.php';
[...]
file2.php
[...]
class Gdl_Ute extends Response_Model {
public $table = SUBDOMAIN.'zi_utp';
public function statuses()
{
[...]
I've used some variants like:
public function __construct()
{
self::$table = SUBDOMAIN.'zi_utp';
}
But there is always an error like:
PHP Parse error: syntax error, unexpected '.', expecting ',' or ';'
or
syntax error, unexpected T_VARIABLE
Thanks very much for any hints! I've also read other similar questions on stackoverflow, but none has answered this problem correctly :/
UPDATE Now I've test the following solutions:
file2.php
public $table;
public function __construct()
{
self::$table = SUBDOMAIN.'zi_utp';
}
OR
file1.php
define('SUBDOMAIN',$subdomain);
const SUBDOMAIN = $subdomain;
RESULT
Access to undeclared static property OR
syntax error, unexpected T_VARIABLE