Is there a way to rewrite the <title> tag of a page using PHP inside the body?

I am new to PHP and wondered if there is a way to rewrite what is displayed in the header tag using PHP inside the body.

Let me explain why I'm trying to do this. I am using forum / cms software which allows me to create PHP pages but will not allow me to change anything in the title (including the title tag). I was hoping there was a script that I could put in the body using PHP, which would replace everything that was displayed in the default title tag.

This is probably a crazy question, and if I'm so sorry.

The thought just ends on how to get what I need in the title.

Thank!

+5
source share
2 answers

.

, Java Script, :

 <script>
 document.title = "This is the new page title.";
 </script>

PHP:

<head><title>some title</title></head>
<body>
   <?php if (some condition, etc) { ?>
   <script>
        document.title = "This is the new page title.";
   </script>
   <?php } ?>
</body>
+4
<html>
    <head>
        <title>Hello</title>
    </head>
    <body>
        <?
            echo "<script>document.title='Hello, World!';</script>";
        ?>
    </body>
</html>
+1

All Articles