I have a question about syntax in php. What is the mean of + in following line? Thanks!
+$array['key1']['key2'] = "value"
I have a question about syntax in php. What is the mean of + in following line? Thanks!
+$array['key1']['key2'] = "value"
It has no meaning, it is superfluous. You can write the exact same statement without the plus:
$array['key1']['key2'] = "value"
If you have that from a unified diff
file, it means that this line was added. So that plus is not PHP code, it is a marker for that line in the diff/patch. The other marker is minus -
for removing a line.
It is used for showing the line diff. in different versions of a same file.
Deleted line can be shown as,
- $array['key1']['key2'] = "value";
Added line can be shown as,
+ $array['key1']['key2'] = "value";
Edit: Apparently I misunderstood the question, so this answer is invalid.
It look like a "shorthand" technique.
+$array['key1']['key2'] = "value"
should be the same as:
$array['key1']['key2'] = $array['key1']['key2'] + "value"
I have never seen it used like this, so I could be wrong. I know it as:
$x++;
is the same as:
$x += 1;
or $x = $x + 1;
and I know that ++$x;
exist also as a pre-increment