I am very new to webscripting and technologies. So please pardon me if this is a very basic query. Further I have been researching this all day and I haven't been able to figure out why this is not working.
I am essentially trying to improve a website for my wife. The design dictates that we have a common header.php file that can be included into the various static pages that the website contains.
Now as a new requirement, they want to target a few static pages targeting different keywords, and for this the company wants to setup a different "Heading Message". So I want to dynamically pass a different "$page_heading" before I include my header.php.
My header.php has a bunch of HTML code with interspersed in between , so the following doesn't seem to be working:
In <mypage.php>:
...
<body>
<div class="container">
<?php
//global page_header;
$page_header = 'A Wildlife Resort of South India';
include('header.php');
?>
...
In <header.php>:
<header class="row-fluid">
<div class="header-main">
<a href="http://www.innthewild.com" class="pull-left"><img src="http://www.innthewild.com/img/itw-logo.png" alt="Inn The Wild" style="margin-top:8px;"/></a>
<div class="pull-right" style="height: 20px;">
<nav>
...
<div class="heading pull-right">
<?php
if(!isset($page_heading)) {
$page_heading = 'A Wilderness Retreat — Masinagudi Jungle Resort, India';
}
echo $page_heading;
?>
</div>
...
The above seems like it should work straight up, but the variable seems to be losing its scope across a new instance. How do I make this work?
Here are the example pages: http://www.innthewild.com and http://innthewild.com/resorts-places-around-bangalore.php