Let's say I have a script, content.php
, which acts as a template. It will get the name of the page from the request. Each page is expected to have a title and meta tag values.
Is there a way that I can set these values from within each page?
The following is a sample:
content.php
<?php
include "header.php";
include "content/{$_GET['page']}.php";
include "footer.php";
?>
header.php
<html>
<head>
<title><?php echo $title ?></title>
<meta name="title" content="<?php echo $meta['title'] ?>">
<meta name="description" content="<?php echo $meta['description'] ?>">
<!-- and other elements that goes here -->
</head>
<body>
footer.php
</body>
</html>
I would like to be able to do something like this WITHOUT adding any includes inside:
page1.php
<?php
$title = 'Some Title';
$meta = ['title' => 'Some Title', 'description' => 'Some Description'];
?>
My Content
And unfortunately, I cannot use any template engines.