Re: ??= and function calls
| From: | mickmackusa | Date: | Thu, 06 Jul 2023 07:18:45 +0000 |
| Subject: | Re: ??= and function calls | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-120755@lists.php.net to get a copy of this message | ||
I didn't even realize that there was a difference between preincrementation
and postincrementation when used in array access.
I guess this is because my default preference is preincrementation and also
that I probably don't use a lot of incrementation while accessing array
data.
I held a false belief that the different syntaxes only mattered when
echoing.
$x = 0;
$array1[1] = 43;
$array1[++$x] ??= 42;
var_dump($x, $array1);
echo "\n---\n";
$y = 0;
$array2[0] = 43;
$array2[$y++] ??= 42;
var_dump($y, $array2);
Thanks Ilija
mickmackusa