search
Homephp教程php手册用文本文件制作留言板提示(下)_php基础

管理你的留言在文本文件中实现不如数据库中那么方便,下面我们想办法来实现这个效果!
在输出的时候我们是用数组来保存数据,那么我们会很方便地为每组数据按顺序分配一个序号,通过对这个序号来操作,我们就可以方便地修改数据!
$date[0]为文本文件中第一行,我们输出时分配序号为0.
输出时有这样的效果:

修改留言
我们再定制modify.php
if($id!=””){
$date=file(“txt/mytxt.txt”);
$str=explode(“&”,$date[0])
?>


  >
>
>
  


}else{
$str=$tech1.”&”. $tech2. ”&”.$tech3….
If($str!=””){
//将修改后的数据写回文本文件!
}
}?>

在这个过程中要注意保持$id的值不丢失,在写回数据时先将文本中的值读入$date,再$date[$id]=$str;
$fp=fopen("txt/mytxt.txt","w");
fwrite($fp,$date);
fclose($fp);
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!