Reply to Re: Echo filename in <title>

Your name:

Reply:


Posted by Steve on 09/24/07 02:30

"geetarista" <geetarista@gmail.com> wrote in message
news:1190600007.908809.136130@19g2000hsx.googlegroups.com...
> On Sep 23, 6:58 pm, macca <ptmcna...@googlemail.com> wrote:
>> function filename_asuc(){
>>
>> $last_dot = strlen(strchr($_SERVER['PHP_SELF'], '.'));
>>
>> $dir = explode('/', substr($_SERVER['PHP_SELF'], 0, - $last_dot));
>>
>> $sep = count($dir) - 1;
>>
>> return ucfirst($dir[$sep]);
>>
>> }
>>
>> // call using this
>> echo filename_asuc();
>
> Thanks everyone! I didn't see the last two posts while I was working
> on this, but this is what I came up with:
>
> <?php
> $path = $_SERVER['SCRIPT_FILENAME'];
> $file = basename($path, '.php');
> $fileName = ucfirst($file);
> ?>
> <title>Company Name - <?php echo $fileName ?></title>
>
> The purpose of this is so that I can include the <title> tags in a
> file called head.php for every page within a web site. This way, I
> don't have to worry about changing or adding the title every time. I
> just include it as part of head.php and will even work if I change the
> name of a file. So when you go to pictures.php, equipment.php,
> jobs.php, or whatever, it will show the correct <title> automatically.

voodoo it is.

> Thanks again for your help and pointing me in the right direction.
> Let me know if this is OK to do and if I should even do it this way.

i did...seems you didn't read my post. the answer is HELL NO!

> I just thought it might make it a little easier for me and others that
> might work on the project.

quite the opposite effect.

> All of the meta tags, scripts, and style
> sheets are the same, so I want to just include DOCTYPE and <head> in
> my head.php.

well, that kind of negates the benefit of having a head.php...don't it. you
should typically include everything up to, and including, <body> ... the
rest is your page specific output.

define whatever you need at the top of the script (variables that are used
in head.php), then do the require/include. your argument about the page name
and file name is mute. even if you change the file name yet have a variable
like $pageTitle that you work from, i bet your script won't morph into
something different than its original purpose...i.e. Pictures. but again,
see my arguments in the previous post. this is bad news.

[Back to original 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

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