Anytime I echo something out in PHP, no matter where the PHP code sits it puts the generated code into the body tag of the html page.
How do I inject html created by PHP into the head tag of the HTML?
for example making the title dynamic or writing a script within the head dynamic.
example code:
<html>
<head>
<?php echo "moo"; ?>
</head>
<body>
</body>
</html>
returns:
<html>
<head>
</head>
<body>
moo
</body>
</html>
EDIT:
I am running it through the server running Nagios this might have something to do with it.
This is happening because you can only have specific tags in your
<head>.You cannot have text nodes (such as “moo”) in your
<head>. The PHP is outputting correctly, but the browser is trying to correct the malformed HTML.More info: https://developer.mozilla.org/en/HTML/Element/head