|
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]
|