PHP minor questions
Hi guys,
Wondering if anyone with PHP know how can tell me if they see a problem with handling a page's title like so.
header.php
title.php
Each of the pages includes the header and footer, etc....
This way i get my titles as "Site name - Directory - Filename"...
The code functions already, i'm just after a few second opinions please..
Hi guys,
Wondering if anyone with PHP know how can tell me if they see a problem with handling a page's title like so.
header.php
Code:
<?php require_once ('title.php')?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Site Name<?php
echo $dir, $page;
?></title>
</head>
<body>
Code:
$ck = 1;
$page = basename($_SERVER['SCRIPT_FILENAME']);
$page = str_replace('_',' ',$page);
$page = str_replace('.php','',$page);
if (strlen($page) > $ck) {
$page = ' - ' .ucfirst($page);
} else {
$page = '';
}
$dir = $_SERVER['PHP_SELF'];
$dir = str_replace(basename($_SERVER['SCRIPT_FILENAME']),'',$dir);
$dir = str_replace('/','',$dir);
if (strlen($dir) > $ck) {
$dir = ' - ' .ucfirst($dir);
} else {
$dir = '';
}
This way i get my titles as "Site name - Directory - Filename"...
The code functions already, i'm just after a few second opinions please..

Last edited: