wepnop Posted February 17, 2011 Share Posted February 17, 2011 # SINGLETON class RegistroGlobal { private static $_instance; var $db; var $config const default_config = array( "index.php"=>"Introducción al ftp", "comandos.php"=>"Comandos básicos", "chmod.php"=>"CHMOD, asignando permisos", "comandosftp.php"=>"Comandos ftp" ); public static function GetInstance() { if (!self::$_instance instanceof self) { self::$_instance = new self(); } return self::$_instance; } # You can suppress the error message on failure by prepending a @ to the function name. private function __construct($conf = default_config) { $this->db = conectar_bd(); $this->config = $conf; // put normal constructor code. // it will only ever be called once } } The default config array gives error. Quote Link to comment https://forums.phpfreaks.com/topic/227970-strange-syntax-problemlarge-array-declaration/ Share on other sites More sharing options...
bh Posted February 17, 2011 Share Posted February 17, 2011 Hi, The value must be a constant expression, not (for example) a variable, a property, a result of a mathematical operation, or a function call. So you cannot assign an array to a class const. Quote Link to comment https://forums.phpfreaks.com/topic/227970-strange-syntax-problemlarge-array-declaration/#findComment-1175551 Share on other sites More sharing options...
wepnop Posted February 21, 2011 Author Share Posted February 21, 2011 Hi, The value must be a constant expression, not (for example) a variable, a property, a result of a mathematical operation, or a function call. So you cannot assign an array to a class const. # SINGLETON class RegistroGlobal { private static $_instance; var $db; var $config; private static default_config = array( "index.php"=>"Introducción al ftp", "comandos.php"=>"Comandos básicos", "chmod.php"=>"CHMOD, asignando permisos", "comandosftp.php"=>"Comandos ftp" ); public static function GetInstance() { if (!self::$_instance instanceof self) { self::$_instance = new self(); } return self::$_instance; } I changued it but i still have a syntax error in the first declaration line. Quote Link to comment https://forums.phpfreaks.com/topic/227970-strange-syntax-problemlarge-array-declaration/#findComment-1177509 Share on other sites More sharing options...
bh Posted February 21, 2011 Share Posted February 21, 2011 hm, what about this line? you forgot the dollar sign before your variable name. private static default_config Quote Link to comment https://forums.phpfreaks.com/topic/227970-strange-syntax-problemlarge-array-declaration/#findComment-1177532 Share on other sites More sharing options...
wepnop Posted February 21, 2011 Author Share Posted February 21, 2011 hm, what about this line? you forgot the dollar sign before your variable name. private static default_config that worked,thanks Quote Link to comment https://forums.phpfreaks.com/topic/227970-strange-syntax-problemlarge-array-declaration/#findComment-1177553 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.