Hello php experts!
I'm trying to find the best practice to include header/footer,
and some general questions about include()
Say I have the following page
<!-- main page -->
<html>
<head>
<title>home</title>
</head>
<body>
<p>Hello World</p>
</body>
</html>
And this is how I break it up in parts.
1. main page
<div class="header"><?php include('header.php') ?></div>
<p>Hello World</p>
<div class="footer"><?php include('footer.php') ?></div>
2. header.php
<?php echo "header.htm" ?>
2.1 header.htm
<html>
<head>
<title>home</title>
</head>
<body>
3. footer.php
<?php echo "footer.htm" ?>
3.1 footer.htm
</body>
</html>
The reason why I'm using two seperate files in each header/footer.php is that,
I have to escape double quotes if I were to design html contents in php directly.
e.g
<?php echo "<a href=\"somelink.html\">some linke</a>" ?>
And I don't want that.
So my questions are;
Q1. Is there a performance penalty by the way I'm including?
Q2. Does include() merely replaces the file content in the source file?
Q3. For footer and header, the include() and include_once()
shouldn't really matter, is this correct?
Q4. Does the file content included by include() gets parsed first,
then gets included in the calling source file? or gets included first, then gets parsed?
Q5. What is the best practice to include header/footer/contents using php?
Thanks.