[thelist] PHP: include not getting variable

Damien COLA damiencola at wanadoo.fr
Wed Jan 7 07:49:47 CST 2004

honestly I don't know. Normally it should know the value of $pagetag
since include is like
if you had the content of includes/navigation.php in your page.
So, your code should work.

Include is not like a function where you have to declare the global

I don't know.
Try a "globals $pagetag;" at the beginning of your included file, but
that is stupid.. I don't know what else to say ;-)

Are you REAL sure this is the EXACT code ? No lower/uppercase in the
names of variables ? or nothing else we should know ?


-----Original Message-----
Posted this before with no answer so trying to rephrase it. I had used
this technique before and it worked, now it doesn't. I have a page
template with a navigation include. Before the include I set a variable
to indicate what page I'm on. The navigation include is supposed to read
that variable, and then add a class to the appropriate anchor. 

Here is the exact PHP code:

<?php $pagetag = "home"; ?>
<?php include("/includes/navigation.php");?>

So i set the name of the page i want... then...in the navigation

<a href="/index.php" <?php if($pagetag == "home") { ?>
class="activePage" <?php } ?> ><span>Home</span></a>

Note that if $pagetag equals the same name as the link, it should right
out the class "activePage" which would make the tab blue not white.

More information about the thelist mailing list