声明类/对象变量/常量时不能调用函数。您也不能使用字符串连接。它相当有限。
更新:您可以使用以下解决方法(编写需要一点时间),它有点难看,因为它需要定义两次常量:
<?php
define('CONFIG_DIRECTORY_RESOURCES', realpath(__DIR__));
define('CONFIG_DIRECTORY_ROOT', $_SERVER['DOCUMENT_ROOT']);
define('CONFIG_DIRECTORY_BRANCH', $_SERVER['DOCUMENT_ROOT'] . '/branch');
define('CONFIG_DIRECTORY_TEMPLATES', CONFIG_DIRECTORY_RESOURCES . '/templates');
define('CONFIG_DIRECTORY_LIBRARY', CONFIG_DIRECTORY_RESOURCES . '/library');
define('CONFIG_DIRECTORY_VIEWS', CONFIG_DIRECTORY_RESOURCES . '/views');
define('CONFIG_DIRECTORY_CONTROLLERS', CONFIG_DIRECTORY_RESOURCES . '/controllers');
define('CONFIG_DIRECTORY_BACKUPS', CONFIG_DIRECTORY_RESOURCES . '/backups');
class Config
{
public static $directories = array(
"resources" => CONFIG_DIRECTORY_RESOURCES,
"root" => CONFIG_DIRECTORY_ROOT,
"branch" => CONFIG_DIRECTORY_BRANCH,
"templates" => CONFIG_DIRECTORY_TEMPLATES,
"library" => CONFIG_DIRECTORY_LIBRARY,
"views" => CONFIG_DIRECTORY_VIEWS,
"controllers" => CONFIG_DIRECTORY_CONTROLLERS,
"backups" => CONFIG_DIRECTORY_BACKUPS,
);
}