I want to print the same page’s name differently based on a certain variable.
Here is a corresponding code.
$metaTitle ="'if($variable=='input'){ title#1 }else { title#2 };'";
And the produced meta title is lately used in the same file to create the page title (<title></title>)
But it keeps producing the title like
if($variable=='input'){ title#1 }else { title#2 };
(the whole if statement as a whole. It does not recognize the if statement. It considers the statement as a plain text.)
What did I do wrong in the sentence??
Because you just assign $metaTitle a STRING “‘if($variable==’input’){ title#1 }else { title#2 };'” and it’s not a runable statement
you should do like this
or simply use Ternary Operator