Include pages with variables in URL

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

MarkAshley
Forum Commoner
Posts: 34
Joined: Fri Nov 18, 2005 1:36 am

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
MarkAshley
Forum Commoner
Posts: 34
Joined: Fri Nov 18, 2005 1:36 am

Post 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().
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post 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');
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
Post Reply