Reply to Re: Echo filename in <title>

Your name:

Reply:


Posted by geetarista on 09/24/07 02:13

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.

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 just thought it might make it a little easier for me and others that
might work on the project. 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.

[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

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