Jump to content

[SOLVED] Functions and page titles


caroa

Recommended Posts

I have several web pages that all use the same includes file, and I wanted to give them unique titles. Therefore I used

 

function title() { echo "Page Title"; }

 

on each page to set the page's title (and title(); in the includes file between <title> and </title>). How would I go about using the includes file for one of my pages, but not breaking the code if I want to include another function that the other pages don't have?

Link to comment
https://forums.phpfreaks.com/topic/180692-solved-functions-and-page-titles/
Share on other sites

Hard to tell exactly what your after from your description so I'll make a guess. When including a global header that you wish to have on multiple pages, but you wish for different head information.

 

home.php

$title = "My title";
include 'header.php';

header.php

<head>
<title><?php echo $title; ?></title>
</head>

 

 

Hard to tell exactly what your after from your description so I'll make a guess. When including a global header that you wish to have on multiple pages, but you wish for different head information.

 

home.php

$title = "My title";
include 'header.php';

header.php

<head>
<title><?php echo $title; ?></title>
</head>

Thank you so much! That didn't answer my question completely, but I somehow figured it out after going off what you wrote. I'm tired because I've been trying to figure out how to do this for a while, so sorry if I'm a bit incoherent. Anyway, you helped me out a lot. Muchas gracias. :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.