Tristan Tristan - 5 months ago 9
PHP Question

How do I assign a HTML title to different pages?

I am developing a website with oure PHP and HTML on an Apache server. No CMS.

All of my website's pages from the main directory and its subdirectories call one

header.php
file.

I have now run into an issue with all of the page
<title>
's, as these are obviously defined in the header, so now I don't know how to set a different title for each page.

Can anyone help?

Answer

What I usually do is have the title tag like this:

<title><? echo $titleIs ?></title>

Then, on each page, before the header include, set the title:

<? $titleIs='Page Title' ?>
Comments