我有一个将变量写入文本文件的脚本,我正在使用 fwrite()。这是脚本:
<?php
error_reporting(E_ALL ^ E_NOTICE);
$filename = 'Report.txt';
$batch_id = $_GET['batch_id'];
$status = $_GET['status'];
$phone_number = $_GET['phone_number'];
//check to see if I could open the report.txt
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
// I am trying to write each variables to the text file
if (fwrite($handle, $phone_number) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
echo "Success, wrote ($phone_number) to file ($filename)";
fclose($handle);
?>
我在这里有两个问题:
1.当我通过 Batch_ID 收到报告时,我想使用 batch_ID 为每个报告文本文件命名,例如:5626_Report.txt
2.我想将多个变量传递给函数fwrite(),我想在每个$phone_number 旁边写下$status。