I want web page to have title of the post being viewed, just as you can see my question as title of this page. I get title from database in a sequence so don't want to run my code before title
tag. Found this question first answers seems reliable but didn't work for me. Is there any similar way by which I can replace the title in title
tag with code at the end of page as at that moment I have title as a sting.
Asked
Active
Viewed 30 times
-2
2 Answers
0
you can change the title dynamically only on the page loads.
<title> <?php echo $title;?> </title>

safin chacko
- 1,345
- 1
- 11
- 18
0
paradigm shift: do all your business logic first.. then generate the page via some sort of templating engine.
Even if it's as simple as storing a bunch of variables $title, $body, $navigation, etc
then
<html>
<head>
<title><?= $title ?></title>
</head>
<body>
<?= $navigation ?>
<?= $body ?>
</body>
</html>
very simplistic example, but hopefully it gets you thinking.
This would be the first baby step to MVC / keeping your code/logic separate from your display/output

Brad Kent
- 4,982
- 3
- 22
- 26