Unexpected T_CONCAT_EQUAL

I get an unexpected T_CONCAT_EQUAL error in a line like this:

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

I am using PHP5. I could just do the following:

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

but I would like to know what happens first. Any ideas?

Thanks Sweeney

+3
source share
3 answers

This will happen when $ arg1 is undefined (it doesn't matter, it has never been set.)

+6
source

So the most accurate reason is because the above line of code is:

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

in my source was as follows:

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

There is no $ value in arg1. I do not know why the interpreter did not catch it first, but whatever it is. Thanks for the contribution of Jeremy and Bailey - this led me to the problem.

+1
source

, .

0

Source: https://habr.com/ru/post/1697887/


All Articles