Skip to content

Instantly share code, notes, and snippets.

@vbarbarosh
Last active April 9, 2019 17:12
Show Gist options
  • Select an option

  • Save vbarbarosh/b2f418c2bac94e63e8a4feeb03a745f1 to your computer and use it in GitHub Desktop.

Select an option

Save vbarbarosh/b2f418c2bac94e63e8a4feeb03a745f1 to your computer and use it in GitHub Desktop.
php_function_scope – Use a function as an scope for variables https://codescreens.com
<?php
# Use a function as an scope for variables
$foo = call_user_func(function () {
$aa = 'Fusce vitae orci lorem.';
$bb = 'In cursus nisi malesuada.';
$cc = 'Etiam auctor, lectus eu lacinia condimentum.';
return implode("\n", [$aa, $bb, $cc]);
});
var_dump(get_defined_vars());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment