Skip to content

Instantly share code, notes, and snippets.

View eldinphp's full-sized avatar
🏠
Working from home

Eldin Egrlić eldinphp

🏠
Working from home
  • Bosnia and Herzegovina
View GitHub Profile
@james2doyle
james2doyle / render-php-file.php
Last active April 4, 2024 15:33
A function to render a php file with data. Allows templating and then sending an array of data into the view.
<?php
function renderPhpFile($filename, $vars = null) {
if (is_array($vars) && !empty($vars)) {
extract($vars);
}
ob_start();
include $filename;
return ob_get_clean();
}
@evansims
evansims / hooks.php
Last active May 20, 2020 19:27
An example of automatically including header and footer templates using Slim hooks.
$app->hook('slim.before.dispatch', function () use ($app) {
$app->render('/views/header.php');
});
$app->hook('slim.after.dispatch', function () use ($app) {
$app->render('/views/footer.php');
});