-2

Why can't I use this concatenation FILEPATH . 'assets/uploads/' in an array ???

$upload = array(
        'path'  =>  FILEPATH . 'assets/uploads/', // Get Parse error: syntax error, unexpected '.', expecting ')'
        'allowed_types' =>  'gif|jpg|png'
    );

I get a syntax error: Parse error: syntax error, unexpected '.', expecting ')'

4
  • 1
    The problem is somewhere else 3v4l.org/8RYLk Commented Jul 27, 2014 at 15:02
  • It isn't a logic error, but syntax. Is something that php doesn't understand?? Commented Jul 27, 2014 at 15:05
  • 2
    Correct. But you have to post code that actually triggers the error. Commented Jul 27, 2014 at 15:07
  • @Álvaro G. Vicario You were right! i put the array inside a method and worked! You shouldn't remove your answer. Commented Jul 27, 2014 at 15:11

1 Answer 1

0

For some reason the concatenation is not working when the array is in a class, but outside a method.

class Foo {
$upload = array(
        'path'  =>  FILEPATH . 'assets/uploads/', unexpected '.', expecting ')'
        'allowed_types' =>  'gif|jpg|png'
    );
}

You have to set it inside a method in order to work

class Foo{
   public function daa(){
        $this->upload = array(
            'path'  =>  FILEPATH . 'assets/uploads/', unexpected '.', expecting ')'
            'allowed_types' =>  'gif|jpg|png'
        );
   }
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.