Skip to content

Instantly share code, notes, and snippets.

@mwhite
Created June 30, 2012 00:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mwhite/3021543 to your computer and use it in GitHub Desktop.
Save mwhite/3021543 to your computer and use it in GitHub Desktop.
Amusing JS vs. PHP comparison
(function foo(x) {
return function bar() {
alert(x);
};
})("foo");
(function foo(x) {
return function bar() {
alert(x);
};
})("foo")();
<?php
call_user_func(function foo($x) {
return function bar() use ($x) {
echo $x;
};
}, "foo");
call_user_func(call_user_func(function foo($x) {
return function bar() use ($x) {
echo $x;
};
}, "foo"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment