Re: Echo filename in <title>



On Sep 23, 7:30 pm, "Steve" <no....@xxxxxxxxxxx> wrote:
"geetarista" <geetari...@xxxxxxxxx> wrote in message

news:1190600007.908809.136130@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx



On Sep 23, 6:58 pm, macca <ptmcna...@xxxxxxxxxxxxxx> 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... ;)

Thanks again!

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

.