D
D
dzhuryn_volodymyr2015-10-06 21:26:58
PHP
dzhuryn_volodymyr, 2015-10-06 21:26:58

Why flock does not work, what to do?

$file_name = 'text.json';
    $fp = fopen($file_name, "r+");
    flock($fp, 2);
    $array = fread($fp, filesize($file_name));
    //flock($fp, LOCK_UN);
    fclose($fp);

    $fp = fopen($file_name, "w+");
    flock($fp, 2);
    fwrite($fp, $array+1); //здесь отработает 
    flock($fp, 3);
    fclose($fp);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DevMan, 2015-10-06
@dzhuryn_volodymyr

and with what fright does he not work out?
Hike, you do not really understand what is lok. or rather, you don’t understand at all: when you lock, other processes
will not be able to write to the file .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question