View Full Version : php title
shimmeringgraphix
June 11th, 2007, 07:50 PM
If using php includes how would I go about having an individual title for each page. In the main header.php I have
<title>Shimmering Graphix.com-<?php echo $title; ?></title>
Then on a individual page I have
<?php $title='Retro Myspace Layouts!'; ?>
But it doesn't work....Help?
Kasami2k4
June 11th, 2007, 07:52 PM
<?phpecho "<title>".(isset($title)?$title:"shimmering graphix."</title>\n";?>
Then on individual page
<?php
$title = "title here";
include('header.php');
?>
Des
June 11th, 2007, 07:53 PM
what error is it throwing?
make sure you have your include at the top of the page before anything else, that way you know that $title is being set before you use it.
shimmeringgraphix
June 11th, 2007, 08:07 PM
<?phpecho "<title>".(isset($title)?$title:"shimmering graphix."</title>\n";?>
Then on individual page
<?php
$title = "title here";
include('header.php');
?>
got this error
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/shimmer/public_html/header.php on line 7
Des
June 11th, 2007, 08:09 PM
try this
<?php echo "<title>".(isset($title)?$title:"shimmering graphix.") . "</title>\n";?>
shimmeringgraphix
June 11th, 2007, 08:15 PM
no error, but still didn't give me a title (besides the shimmering graphix) on the individual page...
niktesla
June 11th, 2007, 10:46 PM
Make sure that:
<?php $title='Retro Myspace Layouts!'; ?>
Is above:
include("header.php");
marshall_26
June 11th, 2007, 11:30 PM
Make sure that:
<?php $title='Retro Myspace Layouts!'; ?>
Is above:
include("header.php");
agreed shimmeringgraphix, your making a call to a string that isn't defined yet so it's returning nothing!
shimmeringgraphix
June 12th, 2007, 07:00 AM
Yeah it is.
I have this in the individual page
<?php
$title = "Retro Myspace Layouts!";
include('http://shimmeringgraphix.com/header.php');
?>
Then this in the header
<?php echo "<title>".(isset($title)?$title:"Shimmering Graphix") . "</title>\n";?>
omen
June 12th, 2007, 07:05 AM
Try this:
<?php
$title = "Myspace Layouts";
include('/home/yoursite/public_html/header.php');
?>
Work out what the full directory structure is for your header file.
For example, mine is
/home/seth/public_html/myspace/header.php
Then on header.php have this in your HTML
<title>Shimmering Graphixx - <?php echo $title; ?></title>
Then if you're given a parse error like before try
<?php echo "<title>".(isset($title)?$title:"shimmering graphix.") . "</title>\n";?> like Des posted.
I think its because you're including an absolute URL..
shimmeringgraphix
June 12th, 2007, 07:11 AM
Try this:
<?php
$title = "Myspace Layouts";
include('/home/yoursite/public_html/header.php');
?>
Work out what the full directory structure is for your header file.
For example, mine is
/home/seth/public_html/myspace/header.php
Then on header.php have this in your HTML
<title>Shimmering Graphixx - <?php echo $title; ?></title>
Then if you're given a parse error like before try
<?php echo "<title>".(isset($title)?$title:"shimmering graphix.") . "</title>\n";?> like Des posted.
I think its because you're including an absolute URL..
That worked, thanks! :)
omen
June 12th, 2007, 07:38 AM
Awesome, glad you got it sorted out!
marshall_26
June 12th, 2007, 01:16 PM
<title>Shimmering Graphixx - <?php echo $title; ?></title>
Yeah isset is more for cookies and forms etc...
regular string echo should work!
vBulletin® v3.7.1, Copyright ©2000-2008, Jelsoft Enterprises Ltd.