Can someone explain how to manage the title tag with PHP?
Can someone explain how to manage the title tag with PHP?
What do you mean? You can echo data inside the <title> tag just like any other tag.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
yeah, like if my title is "This is my Webpage about _________" php would control the blank part pulling from some variables or somethin
<title>This is my Webpage about <?php echo($title);?></title>
... where $title is the variable to put in.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
I would recommend that you use the define function.
Not necessarily... s/he may wish to override it in an include.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
then you replace the title tags in require/header.php with:PHP Code:
<?php define ('TITLE', 'Page Title Here');
//requre the header file
require('require/header.php');
//rest of code here
//require the footer
require('require/footer.php'); ?>
PHP Code:
<title><?php if (defined ('TITLE')) {
print TITLE;
} else {
print 'Site Title Not Set.';
}
?></title>
Yes, but what about:Then s/he can't define the title in the body, which is likely to change, and thus likely to set the title.PHP Code:
<?php define ('TITLE', 'Page Title Here');
// Start output buffering
ob_start();
// Require the body, which will (try to) set a different title for each page
require('require/body1.php');
$body = ob_get_contents();
// End output buffering
ob_end_clean();
//require the header file
require('require/header.php');
echo($body);
//require the footer
require('require/footer.php'); ?>
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Bookmarks