如果猜测了一个数字,如何将两个会话变量中的信息发送到文本文件



我被卡住了,我很乐意得到一些指导。

我需要将同一会话中两个会话变量的信息发送到文本文件。

猜测次数:$_SESSION['antal_gaet']

用户名:$_SESSION['username']

如何写入文本文件,以便从数组中使用(猜测次数、用户名(生成高核心列表。

感谢您提供的任何帮助。

您可以创建/打开一个新文件,然后在其中写入变量的串联:

$scores_file = 'scores.txt';
// open the file
$handle = fopen($scores_file, 'w') or die('Cannot open file:  '.$scores_file);
// create 1rst line and a line feed n
$data = 'Number of guesses:'.$_SESSION['antal_gaet']."n";
// concat the 2nd line
$data .= 'Username:'.$_SESSION['username'];
// write to the opened file
fwrite($handle, $data);

最新更新