我正在尝试将来自数组和cookie(已放入变量,即$usergatsby)的信息写入使用PHP 创建的文本文件中。下面是我想写在文本文件中的代码。我尝试使用 fwrite() 和 file_put_contents 将其写入,但总是出现服务器错误。我想知道是否有人知道我将如何去做这件事?
$emailmsg = "Order: " . foreach ($productarray as $book=>$info)
{if ($book > 0)
{echo $info . ", Quantity: " . $book . "<br><br>";}
} . "// Price: " . $usergatsby*12.99 + $usercatcher*10.99 + $userwaves*8.99 + $userstranger*7.99 + $userulysses*18.99 + $userpride*6.99 + $usermockingbird*9.99 + $userroad*11.99;
$textFile = text.txt;
$fileHandle = fopen($textFile, 'w') or die('There was an error.');
fwrite($fileHandle, $emailmsg);
fclose($fileHandle);