Skip to content

Instantly share code, notes, and snippets.

@mikey179
Created June 28, 2014 20:56
Show Gist options
  • Save mikey179/8ec63defa8e02cc03948 to your computer and use it in GitHub Desktop.
Save mikey179/8ec63defa8e02cc03948 to your computer and use it in GitHub Desktop.
<?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']);
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