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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing vaiables between external php files

Status
Not open for further replies.

atsea

Technical User
Feb 27, 2005
51
JP
I have to pages:

login.html and Content.html

both contain multiple (external) php scripts in the header.

Is it possible to pass variables between all the (necessary) .php files as they are executed.

since the .php files are external and the page being accessed is a .html I don't think its possible to send the varible in the URL and the "GET" it...(or is it...?)

any suggestions?

I guess I could just make the webpage .php and embed all the scripts...but I'm trying to avoid that at the moment.

Thanks

atsea
 
if you are including your "external" scripts through the use of "require()" or "include()" or their "_once" variants all variables in will be available to the php code in those files. If you want the variables to be available in functions you will need to make them explicitly global in those functions. ie.
Code:
$foo = "output";
echo evidence();
function evidence() {
  echo $foo; //nothing will be output (save perhaps an error notice)
  global $foo;
  echo "<br/>"$foo; //"Hello" will be output.
}

superglobals and definitions are available within the full scope of your scripts and their functions and objects etc.
 
You could also use session vars

$_session["var_name"] = "something";

Just put a start session at the top of each page.

Paul Wesson, Programmer/Analyst
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top