Having searched for hours on the forum, I am tearing my hair out. Please help.
My issue is that I am trying to pass a variable to an function defined in an included script.
My function is GenerateHeader() that is defined in the file common.php.
GenerateHeader() contains html for my site logo and menu bar.
The main page for my site, home.php is fed the value of $key from the URL. Home.php includes common.php to generate the top half of the page.
Is there any way to pass $key to the GenerateHeader() function in the included common.php?
Here is some code to illustrate.
home.php -- $key is given a value from the URL ie: home.php?key=value
Code: Select all
<?
include("common.php");
GenerateHeader();
?>
<html>
<head>
</head>
<body>
//HTML for the page content.
<?=$key?>
</body>
</html>Code: Select all
function GenerateHeader() {
?>
<html>
<head>
</head>
<body>
//html for menu bar and top bar ie:
<a href="page2.php?key=<?=$key?>">Page 2</a>
<a href="page3.php?key=<?=$key?>">Page 3</a>
</body>
</html>Thanks in advance.