Simple curiosity about how concatenation works

  for-loop, php

I just want to know why I can do that:

$Hello->World = $Hello->World ?? [];
foreach ($Hello->World as &$world) {
 $world = $Hello->Lorem($world);
}

and complete my variable "$Hello->World" with new values, but can’t do that:

foreach ($Hello->World ?? [] as &$world) {
 $world = $Hello->Lorem($world);
}

The "&$world" reference is broken.

Thanks for help!

Source: Ask PHP

LEAVE A COMMENT