Hi all,
I'm a web designer, and I've been working on some very simple PHP lately. I hope that someone can help me with a strange problem:
I've got a file (index.php) in which I've defined a variable, and called another file. It look something like this:
$name="home";
require("template.php");
That file (template.php) has some xhtml, then it calls a third file:
require("menu.php");
Inside menu.php, I'm trying to use the variable $name from the first file, except it doesn't work. Let me be more specific. I was trying to use $name in a function to add another class to a link. It wasn't adding the class, so I tried echo $name; and found that it doesn't output anything.
My question: is it correct that the variable is supposed to be passed from one file to the next? i.e. shouldn't this work?
If so, can anyone suggest what the problem might be, or do I need to supply more details?
Thanks so much.
I'm a web designer, and I've been working on some very simple PHP lately. I hope that someone can help me with a strange problem:
I've got a file (index.php) in which I've defined a variable, and called another file. It look something like this:
$name="home";
require("template.php");
That file (template.php) has some xhtml, then it calls a third file:
require("menu.php");
Inside menu.php, I'm trying to use the variable $name from the first file, except it doesn't work. Let me be more specific. I was trying to use $name in a function to add another class to a link. It wasn't adding the class, so I tried echo $name; and found that it doesn't output anything.
My question: is it correct that the variable is supposed to be passed from one file to the next? i.e. shouldn't this work?
If so, can anyone suggest what the problem might be, or do I need to supply more details?
Thanks so much.