Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Php - Title in Variable (not working)

Tags:

php

tags

title

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 ??

like image 507
Alex Avatar asked Jul 18 '26 07:07

Alex


1 Answers

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>
like image 168
Sam Aleksov Avatar answered Jul 20 '26 20:07

Sam Aleksov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!