You are here: Re: Echo filename in <title> « PHP Programming Language « IT news, forums, messages
Re: Echo filename in <title>

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

"geetarista" <geetarista@gmail.com> wrote in message
news:1190601458.484015.218990@19g2000hsx.googlegroups.com...
> On Sep 23, 7:30 pm, "Steve" <no....@example.com> wrote:
>> "geetarista" <geetari...@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.
>
> I see where you're coming from, Steve. I did read your first post,
> but I thought that what I was doing was a little different. However,
> I realize now a little better what you were trying to say and I'm
> going to do it your way. It will probably be a little easier that way
> and I'll have a little more freedom. I'll just define the name of the
> title before I include head.php--makes perfect sense! Sometimes I
> guess I make it a little harder than it needs to be... ;)

not 'my way' actually. that's the most typical implementation i've come
across, so i assumed you were doing it in a similar fashion.

> Thanks again!

np.

> p.s. - It's moot--not mute.

i know...i think much faster than my fingers can type. plus, i usually don't
spell check in this forum either. hey, at least i didn't leave out entire
words in this one. ;^)

cheers.

 

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

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