I have seen several posts but I haven't really got around it.

I am finding out PHP is a lot more useful than I thought so I'm trying to use it as much as possible for its flexibility to modify content from a single file.

Can I include the contents of <head> tags inside a php file and then insert it to the html?

like...

<html>
<?php include("head_contents.php"); ?>

<body>
blablabla
</body>
</html>

By the way, would the metatags be included in that head_contents.php as they are usually typed directly into the HTML file?

I will appreciate actual code shown if I am wrong.

Thank you!!!

I think there are no problem using include for <head> tag

commented: irrelevant -1

Here is what i do whenever im doing a sort of template system for clients. Forgive me if there are some errors.

<!-- Head.php -->

<html>
<head>
<!-- All your head links and stuff -->
</head>

<!-- End Head.php -->




<!-- Header.php -->
<body>
<h1> This is the header </h1>
<ul>
	<li>Menu 1</li>
	<li>Menu 2</li>
	<li>Menu 3</li>
</ul>
<!-- End Header.php -->




<!-- Footer.php -->
<div id="footer">
	<h3>&copy; my site | all rights reserved </h3>
</div>
</body>
</html>
<!-- End Footer.php -->




<!-- index.php (main page) -->

<?php include('Head.php') ?>
<?php include('Header.php') ?>

<h1> Any main section content.. like blog posts or a form or something that doesn't change. </h1>

<?php include('Footer.php') ?>
<!-- end index.php -->
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.