D
D
De YURII2015-12-02 02:13:57
PHP
De YURII, 2015-12-02 02:13:57

How to access a file without losing data?

How to access the file in order to read and rewrite data without loss.
Example: one script writes new values, the other reads and deletes, it is necessary that at the moment when they both process the file, the data is not lost. Since the second one can overwrite the data while the first one is adding them, something like this...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stalker_RED, 2015-12-02
@Dejurin

For this there is File locking
flock()
or

file_pit_contents('filename.txt', $my_data, LOCK_EX);

V
Valera Karmanov, 2015-12-02
@motokraft

Use xml file.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question