I want to get my website page title through a function
First I get the Page Name from a function...
function pagetitle() {
global $th, $ta, $tp, $ts, $tc; // <---- Getting the variable value from outside function
global $bl, $qt;
$tit = ucfirst(pathinfo($_SERVER['PHP_SELF'], PATHINFO_FILENAME));
if($tit == "Index") {
echo $th;
}
elseif($tit == "About-us"){
echo $ta;
}
elseif($tit == "Projects"){
echo $tp;
}
elseif($tit == "Services"){
echo $ts;
}
elseif($tit == "Contact-us"){
echo $tc;
}
elseif($tit == "Blog"){
echo $bl;
}
elseif($tit == "Quotation"){
echo $qt;
}
}
Then I tried to get the page title in the format of PageName | PageTitle or PageTitle | PageName...
function getOrg_title(){
$tit = "";
$block = " | ";
global $sl;
$org = $sl['app_org'];
if($sl['title_before'] === 'yes'){
$tit = $org.$block.\pagetitle(); //<----- This should be like "Raj | This is my website"
} else {
$tit = \pagetitle().$block.$org; //<----- This should be like "This is my website | Raj"
}
echo $tit;
}
But not happening...
$tit = $org.$block.\pagetitle(); //<----- Output is "This is my websiteRaj |"
And
$tit = \pagetitle().$block.$org; //<----- Output is "This is my website | Raj"
What should I do ?