Jump to content

Strange syntax problem(large array declaration)


wepnop

Recommended Posts

# 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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.