我无法理解为什么后续代码被Netbeans标记为语法错误表达式。无论如何,这段代码正确地工作到我的项目中,它被定义为一个类。
谢谢!
...
const UPDATE_LISTINI = array(
"TABLE_NAME" => "update_listini",
"TABLE_LOW_FILE_NAME" => "update_listini",
"TABLE_FILE_REGEX" => "update_listini_*",
"TABLE_FILE_NOT_REGEX" => "_[0-9]*$",
"TABLE_FILE_FORMAT" => null,
"TABLE_FILE_SEPARATOR" => null,
"COLUMN_COUNT" => 4,
"INDEX_OF" => array(
"DATA" => 0,
"USER" => 1,
"GRUPPO" => 2,
),
);
const SELECT = "SELECT ";
const FROM = " FROM ";
...
public function sql_getQuery_select_LastUpdate($tablename, $fields){
switch ($tablename){
case self::UPDATE_LISTINI['TABLE_NAME'] : return self::SELECT."MAX(".$fields.") ".self::FROM.self::UPDATE_LISTINI['TABLE_NAME'];
case self::UPDATE_PROMO['TABLE_NAME'] : return self::SELECT."MAX(".$fields.") ".self::FROM.self::UPDATE_PROMO['TABLE_NAME'];
case self::UPDATE_SCONTI['TABLE_NAME'] : return self::SELECT."MAX(".$fields.") ".self::FROM.self::UPDATE_SCONTI['TABLE_NAME'];
}
}
...
答案 0 :(得分:2)
您不能将常量声明为任何类型的语言构造。它必须是静态值。
As of PHP 5.6,您可以在声明中使用一些标量
现在可以在上下文中提供涉及数字和字符串文字和/或常量的标量表达式,其中PHP以前期望静态值,例如常量和属性声明以及默认函数参数。
答案 1 :(得分:0)
你可以这样做
<?php
class CmsAdminMenuHelper {
const ADMIN_MENU_USERS = 1;
const ADMIN_MENU_USERS_NAME = 'Users';
const ADMIN_MENU_CATEGORIES = 2;
const ADMIN_MENU_CATEGORIES_NAME = 'Categories';
const ADMIN_MENU_PRODUCTS = 3;
const ADMIN_MENU_PRODUCTS_NAME = 'Products';
const ADMIN_MENU_STATIC_PAGES = 4;
const ADMIN_MENU_STATIC_PAGES_NAME = 'Static Pages';
const ADMIN_MENU_ADMINSTRATORS = 5;
const ADMIN_MENU_ADMINISTRATORS_NAME = 'Administrators';
const ADMIN_MENU_EMAIL_TRACING = 6;
const ADMIN_MENU_EMAIL_TRACING_NAME = 'Email Tracking';
public static $ADMIN_MENU_ARRAY =array(
self::ADMIN_MENU_USERS => self::ADMIN_MENU_USERS_NAME,
self::ADMIN_MENU_CATEGORIES => self::ADMIN_MENU_CATEGORIES_NAME,
self::ADMIN_MENU_PRODUCTS => self::ADMIN_MENU_PRODUCTS_NAME,
self::ADMIN_MENU_STATIC_PAGES =>self::ADMIN_MENU_STATIC_PAGES_NAME,
self::ADMIN_MENU_ADMINSTRATORS => self::ADMIN_MENU_ADMINISTRATORS_NAME,
self::ADMIN_MENU_EMAIL_TRACING => self::ADMIN_MENU_EMAIL_TRACING_NAME,
);
public static $SUPER_ADMIN_EDIT_VIEW_REMOVE_ARRAY = array(
'view'=>true,
'edit'=>true,
'remove'=>true
);
}