Hello! I am making a site with PHP. I have separated the header into it's own file and used the "include" PHP feature to "fetch" it, sorta like Wordpress. The only problem is I want to change the <title> element for each page. How can I do this?
I was thinking something like this: inside the index.php, contact.php, etc put some PHP code that says "this is the title of the page." Then in the header.php inside the <title> tag have a PHP code that basically looks for the "title of the page" and echos it.
Any help would be appreciated. I will be on the forum and will reply fast. Thanks!
Include Title in < head >
Moderator: General Moderators
Re: Include Title in < head >
Like this:
foo.php
header.php
foo.php
Code: Select all
$title = 'my page title';
require 'header.php';Code: Select all
<html>
<head>
<title><?php echo $title; ?></title>
</head>Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Re: Include Title in < head >
YEAH!! Thank yous.dot wrote:Like this:
foo.phpheader.phpCode: Select all
$title = 'my page title'; require 'header.php';Code: Select all
<html> <head> <title><?php echo $title; ?></title> </head>
I only know a little PHP (mostly Wordpress tags) so I need to learn more and more.