views:

357

answers:

3

Hi All,

I'm getting an unexpected T_CONCAT_EQUAL error on a line of the following form:

$arg1 .= "arg2".$arg3."arg4";

I'm using PHP5. I could simply go an do the following:

$arg1 = $arg1."arg2".$arg3."arg4";

but I'd like to know whats going wrong in the first place. Any ideas?

Thanks, sweeney

+3  A: 

This would happen when $arg1 is undefined (doesn't have a value, was never set.)

yjerem
bingo - turns out i left the $ off of $arg1. not sure why it didnt catch the T_VAR first but close enough. thanks man.
sweeney
A: 

sounds like you forgot a semicolon on the line above this one.

Peter Bailey
A: 

So the most accurate reason is that the above posted line of code:

$arg1 .= "arg2".$arg3."arg4";

was actually as follows in my source:

arg1 .= "arg2".$arg3."arg4";

The $ was missing from arg1. I dont know why the interpreter did not catch that first, but whatever. Thanks for the input Jeremy and Bailey - it lead me right to the problem.

sweeney
When the interpreter comes across something like 'arg1' without quotes or anything, first it checks if it's a defined constant, and if it isn't, it interprets it as the string 'arg1'. So you got the error because it couldn't assign a value to a constant string.
yjerem