Page 1 of 1

Concatenated string disallowed in class properties?

Posted: Fri Jul 30, 2010 2:58 pm
by jraede
I'm pretty sure that I don't have an error in my syntax, so it must be that PHP doesn't allow concatenated strings in property definitions. Is this the case?

This is what I have...

Code: Select all

class slt_handler_form_login extends slt_handler_form {
	protected $form_redirect_failure = SLT_ROOT_URL.'/login/';
	protected $form_redirect_success = SLT_ROOT_URL . '/user/';
       
       ...etc
And it says "Parse error: syntax error, unexpected '.', expecting ',' or ';'", referring to the line with $form_redirect_failure. I made sure that the constant is defined by commenting out the deviant lines and echoing it out in the __construct() method, so that's not the issue.

Since it seems like this is not allowed, is there a way around it? I'd rather not have to prepend SLT_ROOT_URL everywhere the properties are used.

Thanks.

Re: Concatenated string disallowed in class properties?

Posted: Fri Jul 30, 2010 3:52 pm
by John Cartwright
You cannot define anything dynamic in the property definitions. As you mentioned, you need to do

Code: Select all

class slt_handler_form_login extends slt_handler_form {
        protected $form_redirect_failure;
        protected $form_redirect_success;

        public function __construct() {
                $this->form_redirect_failure = SLT_ROOT_URL.'/login/';
                $this->form_redirect_success = SLT_ROOT_URL . '/user/';
        }
}

Re: Concatenated string disallowed in class properties?

Posted: Fri Jul 30, 2010 3:58 pm
by jraede
Gotcha. I actually just realized I had done that with other form controllers, so I guess I thought of that already :-)