Skip to content

Instantly share code, notes, and snippets.

@asm89
Created January 4, 2014 15:13
Show Gist options
  • Save asm89/8256280 to your computer and use it in GitHub Desktop.
Save asm89/8256280 to your computer and use it in GitHub Desktop.
<?php
class App
{
public $callables = [];
public function __construct()
{
register_shutdown_function([$this, 'run']);
}
public function run()
{
foreach ($this->callables as $callable) {
$callable();
}
}
}
$app = new App();
$app->callables[] = function() { echo 'yay'; };
$app->callables[] = function() { echo 'foo'; };
$app->callables[] = function() { echo 'bar'; };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment