phptagstitle

Php - Title in Variable (not working)


I'm using include header in all of my php pages and want to extract each page title and description from a variable , this idea is working on php 5.4 at my local pc (wamp) , but on my host where php 5.2.17 is installed , its not showing title of any page ??

page.php:

<?php
include("header.php");
$title = "Page title";
?>

header.php:

<title><?php echo $title; ?></title>

any help please ??


Solution

  • You're displaying the value of $title before the assignment.

    page.php:

    <?php
       $title = "Page title";
       include("header.php");
    ?>
    

    header.php:

    <title><?php echo $title; ?></title>