Page 2 of 2

Posted: Sat Nov 04, 2006 6:12 am
by MarkAshley
feyd wrote:The value you give to include() can only be a file location. Nothing else.
That's all I needed to know. Thanks :D I think allowing variables in include() would be a useful addition to php.

Posted: Sat Nov 04, 2006 7:29 am
by feyd
MarkAshley wrote:I think allowing variables in include() would be a useful addition to php.
Why? All the variables that are available in the script at the time of the call to include()/require()/etc are available to the included file.

Posted: Sat Nov 04, 2006 8:47 am
by MarkAshley
I have a requirement to pass a page and some variables to a script, which get included. The variables which also get included aren't the same every time. So I have to store the variables somewhere else and then retrieve them later. It would be easier if I could just add them to the URL I include().

Posted: Sat Nov 04, 2006 9:05 am
by Burrito
if you're hell bent on using get vars, and you don't want to include them in your url just set them above your include.

ie:

Code: Select all

$_GET['something'] = "some value";
include('somefile.php');

Posted: Sat Nov 04, 2006 9:14 am
by RobertGonzalez
MarkAshley wrote:I have a requirement to pass a page and some variables to a script, which get included. The variables which also get included aren't the same every time. So I have to store the variables somewhere else and then retrieve them later. It would be easier if I could just add them to the URL I include().
If you have the value to populate the querystring then you have the values you need use in the included file.