I am making a php site without using a database. I add the header and footer to the page with the include function.
How can I dynamically create meta tags by pulling information from inside the page.
<?php include "inc/head.php" ?>
<main>
<article>
<h1>Page Name</h1>
<div>Post Body</div>
</article>
</main>
<?php include "inc/footer.php" ?>
CodePudding user response:
The point is: first, define your php variables; then use them when needed. for example
in the "inc/head.php"
file define the variables so you can access them later like
$page_name = 'The Page Name';
so now you can set your h1
context like
<h1><?php echo $page_name; ?></h1>