if statement on page title

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
REwingUK
Forum Commoner
Posts: 26
Joined: Wed Jul 29, 2009 8:46 pm

if statement on page title

Post by REwingUK »

I'm trying to add an if statement to the title of my webpage.

I basically want to say if the page is on detail.php then show this title, else show the normal title. Any ideas?

Code: Select all

if $pageurl = detail.php {
 
<title><? echo $tt_45['Address']." "; ?></title>
 
}
else 
{
<title>Normal Title</title>
}
 
Thanks in advance
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: if statement on page title

Post by s.dot »

Code: Select all

<?php
$title = !empty($_SERVER['PHP_SELF']) && (basename($_SERVER['PHP_SELF']) == 'detail.php') ? 'detail page title' : 'normal title';
 
echo '<title>' . $title . '</title>';
?>
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.
Post Reply