Page 1 of 1

Include?

Posted: Fri Jun 17, 2005 9:28 pm
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

Posted: Fri Jun 17, 2005 9:45 pm
by Skara
Don't know why you'd want to use $_GET for that...

Code: Select all

$_GET['id'] = 'go';
include('header.php');

Posted: Sat Jun 18, 2005 9:24 am
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.

Posted: Sat Jun 18, 2005 9:27 am
by cjermain
That solves the problem.

Thanks!

-Colin J

Posted: Sat Jun 18, 2005 9:32 am
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

Posted: Sat Jun 18, 2005 1:20 pm
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.