Skip to content
Advertisement

pull data from page without database

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" ?>

Advertisement

Answer

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>
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement