Skip to content

Instantly share code, notes, and snippets.

@gustavo-rodrigues-dev
Last active March 16, 2017 20:31
Show Gist options
  • Save gustavo-rodrigues-dev/682589adeab255f5474555b2daa86212 to your computer and use it in GitHub Desktop.
Save gustavo-rodrigues-dev/682589adeab255f5474555b2daa86212 to your computer and use it in GitHub Desktop.
sync exemple of scrip
<?php
$names = [];
$add = function($str) use(&$names)
{
sleep(10);
array_push($names, $str);
return $str;
};
var_dump($names); // array(0) { }
echo $add('Gustavo'); // Gustavo
var_dump($names); // array(1) { [0]=> string(7) "Gustavo" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment