0

First: I have read all of the possible duplicate posts for this, and I have looked over several sources of documentation and examples, which I have replicated in the below code. However I'm getting syntax errors when writing this in Aptana 3. Is this syntax not legal, or is it perhaps a problem with my environment?

class Story {       
    private $storyText;

    function build () use ($storyText)  {
        $storyText .= "blabla";
    };
}

1 Answer 1

2

It is a syntax error. The use statement in this form isn't allowed for a class method. It is for closures only.

I guess you want something like this:

class Story {       
    private $storyText;

    public function build ()   {
        $this->storyText .= "blabla";
    };
}

Try to start with PHP's OOP Basics described in the manual.

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.