Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using querystring with require()

Status
Not open for further replies.

Microbe

Programmer
Oct 16, 2000
607
AU
Hey there,

It seems you can't do something like
Code:
require("myfile.php?action=edit");
PHP looks for the file name literally and won't find the file "myfile.php?action=edit"

Does anyone know of a way to pass a parameter using require()?

Thanks in advance.

Steve
- I have fun with telemarketers
 
you just tell php what protocol you want to use.
Code:
require("[red][URL unfurl="true"]http://mydomain.com/[/URL][/red]myfile.php?action=edit");

remember a query string is a web server thing. but note that you will receive the value of the executed code when called across a webserver connection.

however you can use other methods too because required files share the same scope as the functions or methods that require them.

so if you set $action = 'red'; the line before the require, the variable $action will be available to the script in myfile.php. and to make the variable available to any function within myfile.php you would, as normal, use the global keyword.
 
Thanks for the suggestions.

fopen isn't available on the server.

Also the server doesn't allow using a link to http://

But I can't believe I didn't think of the obvious method of a global variable.

Appreciate your help

Steve
- I have fun with telemarketers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top