Я не могу найти папку с именем invoice и не уверен, правильный ли мой код или нет
Я пытался изменить запись на запись и чтение, но она все еще не создала файл впапка для меня ...
$invoice = "------------------------------------\n";
$invoice .= "Level 1 Monthly Subscriptionplan Information\n";
$invoice .= $level1."\n";
$invoice .= "Subscriptionplan:".$row['subscriptionplan']."\n";
$invoice .= "Enrollment Date:".$row['subscriptionplandate']."\n";
$invoice .= "Monthly Fees:".$row['feesmonthly']."\n";
$invoice .= "Payment Status:".$row['paid']."\n";
$invoice .= "Expiry Date:".$row['expirydate']."\n";
$invoice .= "Payment Due Date:".$row['paidbydate']."\n";
$myfile='invoice/level1monthly/'.$_SESSION['u_uid'].'.txt';
$fh = fopen($myfile, 'w+') or die("can't open file");
fwrite($fh, $invoice);
fclose($fh);
Я ожидаю, что она создаст папку с именем invoice в моей корневой директории моего живого сервера
Level 3 Monthly Subscriptionplan Information
Subscriptionplan:
Enrollment Date:
Monthly Fees:0
Payment Status:
Expiry Date:
Payment Due Date:
Я сделал следующий код, но могуне могу изменить его, чтобы добавить
$invoice .= "Level 1 Monthly Subscriptionplan Information\n";
$invoice .= $level1."\n";
$invoice .= "Subscriptionplan:".$row['subscriptionplan']."\n";
$invoice .= "Enrollment Date:".$row['subscriptionplandate']."\n";
$invoice .= "Monthly Fees:".$row['feesmonthly']."\n";
$invoice .= "Payment Status:".$row['paid']."\n";
$invoice .= "Expiry Date:".$row['expirydate']."\n";
$invoice .= "Payment Due Date:".$row['paidbydate']."\n";
$myfile='invoice/level1monthly'.$_SESSION['u_uid'].'.txt';
$fh = fopen($myfile, 'a+') or die("can't open file");
fwrite($fh, $invoice);
fclose($fh);
} else {
$invoice = "------------------------------------\n";
$invoice .= "Level 1 Monthly Subscriptionplan Information\n";
$invoice .= $level1."\n";
$invoice .= "Subscriptionplan:".$row['subscriptionplan']."\n";
$invoice .= "Enrollment Date:".$row['subscriptionplandate']."\n";
$invoice .= "Monthly Fees:".$row['feesmonthly']."\n";
$invoice .= "Payment Status:".$row['paid']."\n";
$invoice .= "Expiry Date:".$row['expirydate']."\n";
$invoice .= "Payment Due Date:".$row['paidbydate']."\n";
$myfile='invoice/level1monthly'.$_SESSION['u_uid'].'.txt';
$fh = fopen($myfile, 'w+') or die("can't open file");
fwrite($fh, $invoice);
fclose($fh);
}
Это мой обновленный код ... Будет ли это работать с точки зрения создания нового файла, если он не существует, а затем добавить его?
$myfile='invoice/level1monthly'.$_SESSION['u_uid'].'.txt';
if(file_exists($myfile)) {
$invoice = "------------------------------------\n";
$invoice .= "Level 1 Monthly Subscriptionplan Information\n";
$invoice .= $level1."\n";
$invoice .= "Subscriptionplan:".$row['subscriptionplan']."\n";
$invoice .= "Enrollment Date:".$row['subscriptionplandate']."\n";
$invoice .= "Monthly Fees:".$row['feesmonthly']."\n";
$invoice .= "Payment Status:".$row['paid']."\n";
$invoice .= "Expiry Date:".$row['expirydate']."\n";
$invoice .= "Payment Due Date:".$row['paidbydate']."\n";
$fh = fopen($myfile, 'a+') or die("can't open file");
fwrite($fh, $invoice);
fclose($fh);
} else {
$invoice = "------------------------------------\n";
$invoice .= "Level 1 Monthly Subscriptionplan Information\n";
$invoice .= $level1."\n";
$invoice .= "Subscriptionplan:".$row['subscriptionplan']."\n";
$invoice .= "Enrollment Date:".$row['subscriptionplandate']."\n";
$invoice .= "Monthly Fees:".$row['feesmonthly']."\n";
$invoice .= "Payment Status:".$row['paid']."\n";
$invoice .= "Expiry Date:".$row['expirydate']."\n";
$invoice .= "Payment Due Date:".$row['paidbydate']."\n";
$myfile='invoice/level1monthly'.$_SESSION['u_uid'].'.txt';
$fh = fopen($myfile, 'w+') or die("can't open file");
fwrite($fh, $invoice);
fclose($fh);
}