Skip to content

Instantly share code, notes, and snippets.

@dhrrgn
Last active August 29, 2015 14:01
Show Gist options
  • Save dhrrgn/1480e6ad90ac394e43eb to your computer and use it in GitHub Desktop.
Save dhrrgn/1480e6ad90ac394e43eb to your computer and use it in GitHub Desktop.
<?php
function require_in_context($__path, array $__context)
{
extract($__context, EXTR_SKIP);
unset($__context);
ob_start();
require $__path;
return ob_get_clean();
}
@ircmaxell
Copy link

Be sure to add EXTR_SKIP to extract to prevent it from overwriting the $__path variable.

extract($__context, EXTR_SKIP)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment