I need to create titles dynamically for a script that I'm doing, the title should be depending on the file that is in use currently.
My structure script is:
@require_once"bd.php";
@require_once"Funciones/functions.php";
include head.php;
include body.php;
include footer.php;
My title function code is called from head.php
this is my function, but not works always returns blank result :s
function get_title(){
$indexurl = "index.php";
$threadurl = "post.php";
$searchurl = "search.php";
$registerurl = "register.php";
$query = $_SERVER['PHP_SELF'];
$path = pathinfo( $query );
$url = $path['basename']; //This returns the php file that is being used
if(strpos($url,$indexurl)) {
$title = "My home title";
}
if(strpos($url,$threadurl)) {
$title = "My post title";
}
if(strpos($url,$searchurl)) {
$title = "My search title";
}
if(strpos($url,$registerurl)) {
$title = "My register page title";
}
return $title;
}
Im call the function:
<title><? echo get_title(); ?></title>