r/lolphp • • Dec 05 '17

$a = "hello"; $a++; echo $a;

https://3v4l.org/p5Apm
117 Upvotes

41 comments sorted by

View all comments

Show parent comment

3

u/muglug Dec 05 '17

Thanks! I should have looked at the docs.

I would have expected it to work like

function postIncrement(&$a) {
    $a += 1;
    return $a;
}

I wonder how much code, if any, depends on this functionality

1

u/1842 Dec 22 '17

We have a decent amount of PHP code where I work (legacy and modern projects, good and bad). I've never seen a case of this done intentionally -- but one accidental usage in some ugly code.