這是我的代碼,我有用於生成新文件的計數器值。我通過ajax將單位值傳遞給php。每當我改變單位值時,我想重置計數器值。怎麼做?如何重置計數器值?
$v=$_GET['v'];
$project=$_GET['p'];
$unit=$_GET['u'];
echo $unit ;
$a_str = array($_POST["content"]);
$a_url = $_POST["url"];
$contents = implode(PHP_EOL, $a_str);
$filename = file_get_contents($project."/counter.txt");
$counter = file_exists($project.'/counter.txt') ? file_get_contents($project."/counter.txt")+1 : 1 ;
$contents .= PHP_EOL . PHP_EOL;
file_put_contents($project."/unit-".$unit.'.'.$counter."-".$v.".html",$contents);
file_put_contents($project."/counter.txt",$counter);
你在哪裏更改單位價值? –
我通過UI更改了單位值 – user2653831
代碼中的變化在哪裏? –