2 ways come to mind - one's messy one isnt! Non-Messy: You could put $var1 into an include file, and include it in both file1.php and file2.php, eg:
//Inc.php $var1 = "some value"; //file1.php include('Inc.php'); $var1 == "some value"; //file2.php include('inc.php'); $var1 == "some value"; $var1 will be avaliable in both files. inc.php could, of course have some code in it to set the variable (for example a random number etc). $var1 would also be avaliable to any other scripts that may need it in the future, just by including the inc.php file. Messy: Open file1.php from file2.php and read the variable out of it... ***MESSY, SLOW AND DIRTY*** Craig Roberts "Kalle Saarinen" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello > > I was just wondering how can I get value of a variable in php code located > in a different file? > > ie. > > I have file1.php wich stores $var1 > how can I read the value of $var1 in file2.php > > I have database and I can put it in there (I quess) but is that the only > way? > > -Kalle > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php