I need to save a variable as a text file, then open it in another script, and use the number from the file as a variable in that script. How can this be done?
File 1:
// your variable $var = 5; // write it to a file $fp = fopen('file.txt', 'w'); fwrite($fp, $var ); fclose($fp);
File 2:
// get the first line of the file // and save it as $varval list($varval) = file('file.txt'); echo $varval;
-- lilleman
Originally posted by lilleman File 1: // your variable $var = 5; // write it to a file $fp = fopen('file.txt', 'w'); fwrite($fp, $var ); fclose($fp); File 2: // get the first line of the file // and save it as $varval list($varval) = file('file.txt'); echo $varval; -- lilleman [/B]
Originally posted by lilleman File 1:
-- lilleman [/B]
The code seems to work, the problem is that I can't save to my server without logging in. Is there a workaround to that problem?