You are here: Re: <title> in the body (I know it's wrong) « HTML « IT news, forums, messages
Re: <title> in the body (I know it's wrong)

Posted by Toby A Inkster on 07/30/07 13:13

Paul Furman wrote:

> I know it's wrong but it works: putting the <title> in the body of the
> document inside another <head> because I'm generating this with php &
> kind of boxed myself into not having access to the text I want till I
> get well into the body

<?php

// I don't know the title yet, so I'll turn on output buffering and
// then output an empty title.
ob_start();
print "<html>\n";
print "<head>\n";
print "<title></title>\n";
print "</head>\n";

// OK. Now I know what the title is, so switch off output buffering
// and replace the empty title with the known title.
$title = 'Lalala';
print str_replace('<title></title>',
"<title>$title</title>",
ob_get_clean());

?>

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 39 days, 16:46.]

demiblog 0.2.2 Released
http://tobyinkster.co.uk/blog/2007/07/29/demiblog-0.2.2/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация