So, I'm trying to build a template-loader system with PHP. Here's what I got so far:
config.php:
<?php
$style_assets_path = "/includes/styles/";
if ($_GET['page_id'] !== '1'){
header('Location: /template.php?pageid=1');
exit(0);
}
if ($_GET['page_id'] <= 100) {
$template = "/main/main.php";
}
function loadTemplate() {
require_once dirname(__FILE__) . "$style_assets_path" . "templates" . "$template";
// This should output: /includes/styles/templates/main/main.php
}
?>
home.php:
<?php
require_once dirname(__FILE__) . "/config.php";
loadTemplate($template);
?>
So I get the following error when I open home.php:
Warning: require_once(/home/xxxxxxx/public_htmltemplates/) [function.require-once]: failed to open stream: No such file or directory...
What am I doing wrong?
require_oncething it's showing you.public_htmltemplatesprobably isn't right!"$style_assets_path"like$style_assets_path. And"$template"as well