In example 4 (Values from the outer scope cannot be modified by arrow functions)
<?php
$x = 1;
$fn = fn() => $x++; // Has no effect
$fn();
var_export($x); // Outputs 1
?>
Here we can use reference variable in fn(&$x) and pass the value from function call $fn($x) so that we will get the output as expected with out using Anonymous functions.
Example:
<?php
$x = 1;
$fn = fn(&$x) => $x++;
$fn($x);
var_export($x);
?>
Output : 2 (as expected)
But here it will not take values from parent scope automatically but we have to pass them explicitly.