Php 是否重置电子邮件主题中的订单计数?
我想向客户发送一封电子邮件,邮件主题为每个订单的订单(#1)、订单(#2)等。在月初发送电子邮件时,它将重置为订单(#1)?好,让我们看看Php 是否重置电子邮件主题中的订单计数?,php,Php,我想向客户发送一封电子邮件,邮件主题为每个订单的订单(#1)、订单(#2)等。在月初发送电子邮件时,它将重置为订单(#1)?好,让我们看看 <?php if(file_exists("id.txt")) { $storedID = unserialize(file_get_contents('id.txt')); } else { $storedID = 1; $toStoreID = serialize($storedID
<?php
if(file_exists("id.txt")) {
$storedID = unserialize(file_get_contents('id.txt'));
} else {
$storedID = 1;
$toStoreID = serialize($storedID);
$handleID = fopen('id.txt','w+');
fwrite($handleID, $toStoreID);
}
function sendEmail(){
saveID();
global $storedID;
echo "Order No (".$storedID.")";
// $to = "customer@domain.com";
// $subject = "Hello "Order No (".$storedID.")";
// $body = "Hi,\n\nTahnks God For Stackoverflow";
// if (mail($to, $subject, $body)) {
// echo("<p>Message sent!</p>"); // Put saveID(); here so failed emails dosen't count !
// } else {
// echo("<p>Message delivery failed</p>");
// }
}
function saveID(){
global $storedID;
$today = date("d");
if($today == 01 && file_exists("1st.txt")){
$storedID = $storedID+1;
$toStoreID = serialize($storedID);
$handleID = fopen('id.txt','w+');
fwrite($handleID, $toStoreID);
} else if($today == 01 && !file_exists("1st.txt")){
fopen('1st.txt','w+');
$storedID = 1;
$toStoreID = serialize($storedID);
$handleID = fopen('id.txt','w+');
fwrite($handleID, $toStoreID);
} else {
$storedID = $storedID+1;
$toStoreID = serialize($storedID);
$handleID = fopen('id.txt','w+');
fwrite($handleID, $toStoreID);
}
if ($today != 01 && file_exists("1st.txt")){
unlink("1st.txt");
$toStoreID = $toStoreID+1;
}
}
sendEmail();
?>
如果你每天发送一封电子邮件,这很简单,但如果不是,请解释更多,你知道数据存储、数据访问(文件、数据库)吗?如果是读写文件并在一个月的第一天触发一个动作,这就是你需要的:文件获取内容()
()和文件放置内容()
()如果日期('j')==1
()。当前计数与订单号(23)类似。我希望将计数与订单号(1)类似,而将日期“01”重置为系统日期(或)服务器日期。