Include?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
cjermain
Forum Newbie
Posts: 12
Joined: Wed Jun 01, 2005 6:11 pm

Include?

Post by cjermain »

Hey,
Im using a javascript function inside my header.php, which I include on every page. On a certain page I want the header.php to change its contents a little so that the javascript will run (by changing the body tag to body="cookiecheck()") . How do I tell the included page to execute the change?

Sessions or Cookies or ______________ ?

Is there any way to include like this:

Code: Select all

<?php include('header.php?id=go'); ?>
...were there is a $_GET value?

Thanks!

-Colin J
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

Don't know why you'd want to use $_GET for that...

Code: Select all

$_GET['id'] = 'go';
include('header.php');
User avatar
cjermain
Forum Newbie
Posts: 12
Joined: Wed Jun 01, 2005 6:11 pm

Post by cjermain »

The reason I would prefer not to use sessions or cookies and rather $_GET, is because the javascript that I am trying to run checks to see if javascript and cookies is enabled on my users browser. I cant make it run with cookies because it would only run on users with cookies and defeat the purpose of the script.
User avatar
cjermain
Forum Newbie
Posts: 12
Joined: Wed Jun 01, 2005 6:11 pm

Post by cjermain »

That solves the problem.

Thanks!

-Colin J
AGISB
Forum Contributor
Posts: 422
Joined: Fri Jul 09, 2004 1:23 am

Post by AGISB »

I simply set a var at the pages that are different.

So do a

Code: Select all

$pagejava = 'yes'
in front of the include

You can vary the value for your needs. As all variables are valid for the include and vice versa there is no need to use get or sessions or cockies
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

Imagine include() as sticking the code from the other file in the file that includes it before it runs. That's basically what happens.
Post Reply