English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

i have a school project to make a game in php so i need a function that will delete the content of a ".txt" file.. the idea is that every time the user go to page1.php a variable is put in a text file named "game.txt" and when the user go to the next page page2.php, it will load the content of game.txt.... what i want to do is to erase the content of game.txt after loading it in page2.php.... any suggestions??

2007-02-02 11:03:38 · 1 answers · asked by sam_f 4 in Computers & Internet Programming & Design

1 answers

Try just erasing it
unlink("wherever/game.txt)";

and create game.txt from start.

or try fopen("game.txt", "w");

w tells f open to open the file for writing, start writing from the beginning of the file and if the file already exists delete the contents. if the file does not exist create it. if you pass w+ then it opens the file for reading and writing.

2007-02-03 04:19:04 · answer #1 · answered by jason b 5 · 0 0

fedest.com, questions and answers