Created
June 28, 2014 20:56
-
-
Save mikey179/8ec63defa8e02cc03948 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function foo(callable $bar) | |
{ | |
$bar("nu?\n"); | |
} | |
foo(function($arg) { echo "Hello world!\n" . $arg;}); | |
function baz($arg) | |
{ | |
echo "Hello baz\n" . $arg; | |
} | |
foo('baz'); | |
class Yo | |
{ | |
function hey($arg) | |
{ | |
echo "Yo!\n" . $arg; | |
} | |
static function ho($arg) | |
{ | |
echo "Yo?\n" . $arg; | |
} | |
function __call($method, $args) | |
{ | |
echo "Ha jo\n", $args[0]; | |
} | |
static function __callStatic($method, $args) | |
{ | |
echo "Ha noi!\n" . $args[0]; | |
} | |
} | |
foo(['Yo', 'ho']); | |
foo(['Yo','other']); | |
$yo = new Yo(); | |
foo([$yo, 'hey']); | |
foo([$yo, 'noi']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hello world! | |
nu? | |
Hello baz | |
nu? | |
Yo? | |
nu? | |
Ha noi! | |
nu? | |
Yo! | |
nu? | |
Ha jo | |
nu? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment