0

I have a Config class with:

class Config{
    [...]
    public static function url()
    {
        if(self::debug)
            return "https://localhost:44300";
        else
            return "https://www.mysite.com";
    }
    [...]
}

then a class to manage Facebook logins, where I want to define a string with the callback uri:

class Fb
{
    public static $login_redirecturi = Config::url() . "/login/";
    [...]
}

But I can't understand why it gives an error:

Parse error: syntax error, unexpected '(', expecting ',' or ';' in [...] on line 20

enter image description here

How can I do?

1 Answer 1

3

You can't call methods on property declarations.

From the PHP docs:

This declaration may include an initialization, but this initialization must be a constant value--that is, it must be able to be evaluated at compile time and must not depend on run-time information in order to be evaluated.

http://php.net/manual/en/language.oop5.properties.php

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.