So I have this PHP website that I am working on that using templates. Any page is divided into three parts: header, content and footer. Each part is represented by a .php file.
Header:
<html>
<head><link_to_some_css /></head>
<body>
<div id="menuBar">
xxx
</div>
Content:
<?php include("header.php") ?>
<div id="someHTMLContent">xxx</div>
<!--
How do I link an external CSS stylesheet from within here?
-->
<?php include("footer.php") ?>
Footer:
</body></html>
The <link> tag should resides within the <head>, but being within content.php I have no access to the head of the html.
Sorry if this has been asked, but I am a little new to implementing a framework-less PHP project in an MVC architecture (hence trying to separate CSS JavaScript PHP files for a better structure)
If you want something included in the header then make it a global variable before including.
In the header.php:
You could add a more robust solution by defining functions to create CSS tags given a link and then add them into the global $header string. These would need to be included from a
core.phpfile included before the header include.