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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.