Page 1 of 1

Dynamic Include

Posted: Tue Aug 23, 2005 9:02 pm
by AliasBDI
I am making a print page that will dynamically include a page which is passed in the URL. I am able to dynamically include the file, but the file path has a variable passed in it (ex: "page.php?var=22"). The include is giving me an error when it contains the variable. But without it, it is fine (ex: "page.php").

Any ideas?

Posted: Tue Aug 23, 2005 9:15 pm
by nielsene
you can't pass GET style variables in an include statement. However the included file is run in the same context as the include call. So if you want to "pass" a variable named "var" to the included script simply do

Code: Select all

$var=22;
include("page.php");
the script in page.php can now use $var.

Posted: Tue Aug 23, 2005 9:31 pm
by AliasBDI
Great idea. Thanks.


... works great ...