Re: Re: passing variables

From: Date: Mon, 14 Jan 2002 14:47:32 +0000
Subject: Re: Re: passing variables
Groups: php.windows 
Request: Send a blank email to php-windows+get-11423@lists.php.net to get a copy of this message
There is NO need for that... When including a file it's as if the file were inline with the code in the spot in which include() is called. You may want to use require() to make sure that the file is actually being added. Also you just need to use $data wherever you want.. Or you can do it like this: $sign = $data;
when you call the 2nd script, new.php, call it like this: new.php?sign=$data that is one way to pass it ... or you can keep the variable hidden by using sessions 1. xmlparse.php -------------------------------
session_start();     // start a session
session_register("data"); // register 'data' as a session var
$data = "whatever";        // assign a value
--------------------------------- 2. now going on to the next script: new.php --------------------------------- session_start(); // start a session $sign = $data; // $data should already have the value previously assigned; since it's in session, the value carries over echo $sign; // should display "whatever" ------------------------------------------- try that. also, you can try doing this in your original example: <snip> new.php include('xmlparse.php')
 global $data;           // add this line; do a "global" to make sure you
grab the $data var $sign = "$data"; echo "$sign"; </snip> Goodluck! Nicole Amashta www.aeontrek.com ======================== "Sandeep Murphy" <Sandeep.Murphy@oni.pt> wrote in message news:69E9C8885D77554CAF2A7C5C690F43595B61A8@arexcprd01.e3g.pt... hi all, I have a variable in a file called xmlparse.php called $data. $data stores in it an output returned by another php script.. I need to pass this variable $data now into yet another php file say new.php .. xmlparse.php $data = "blah blah"; -------------------------------------------------------------------------- -- ---- new.php include('xmlparse.php') $sign = "$data"; echo "$sign"; But my echo "$sign"; is NOT printing anything.. Whats wrong here?? TIA, -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net For additional commands, e-mail: php-windows-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net
_________________________________________________________________ Join the world’s largest e-mail service with MSN Hotmail. http://www.hotmail.com

« previous php.windows (#11423) next »