-
-
Save tadeubdev/eedadf3e7260d39b3204 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 renderPhpFile($filename, $vars = null) | |
{ | |
if (is_array($vars) && !empty($vars)) | |
{ | |
extract($vars); | |
} | |
ob_start(); | |
include $filename; | |
return ob_get_clean(); | |
} | |
// usage | |
echo renderPhpFile('views/templates/index.php', $data_for_view); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment