A
A
Alexander Fedoruk2014-03-08 19:46:43
PHP
Alexander Fedoruk, 2014-03-08 19:46:43

How is the file system organized in PHP?

I just started learning PHP yesterday. I wrote a simple program for the practice of working with files:
1 - Open the file -> read the number -> display it
2 - The user presses the button -> increase the number
3 - Write the new number to the file -> Save

Calculation that different users together influence to that same number. And if two users access the file at the same time, will an error occur? Or is there some kind of protection in PHP?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rowdy Ro, 2014-03-08
@AlexSaFF

use flock to avoid stale data
ru2.php.net/manual/ru/function.flock.php

P
Push Pull, 2014-03-08
@deadbyelpy

You are most likely opening the file in blocking mode.
Those. until the document is released, another write will not go through.
For accuracy, attach the source to the question.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question