0

The "syntax error unexpected ','" error is occurring here:

$foo1 = ($foo2, true);

Is the comma not suppose to be there?

2
  • Yep. You probably mean something like foo($foo2, true);, the function name being the difference. ;) Commented Dec 28, 2010 at 7:32
  • what are you trying to do there ? usualy you use () for math , passing function arguments arrays or whatever but you're not doing any of those Commented Dec 28, 2010 at 7:36

2 Answers 2

3

You are either trying to create an array:

$foo1 = array($foo2, true);

Or calling a function:

$foo1 = myFunc($foo2, true);

Or trying to use a C comma expression, which PHP does not support (then again in that case $foo1 would just be assigned to true).

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

2 Comments

btw, array() is also function :)
@heximal: No, it's a language construct. The manual lists it as a function only because it does the same for include, require, echo, print, etc, which are all language constructs. Syntactically you can call them like functions, but they're not.
0

This is not a valid php expression.

$foo =myfunc($foo2, true);

Will call the function myfunc with the parameters $foo2 and true. The result will then be assigned to $foo.

$foo = array($foo2, true);

Will create a new array with two elements($foo2 and true)

$foo = ($foo2, true);

Will just throw a parse error because the only valid symbols between to variables in this context are operators(+,-,%,AND,...).

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.