Syntax
bool flock
(
file_name ,lock
[,block] )
lock values are
Code for flock() function PHP
<?php
$file = fopen("c:/rose1/ram.txt","w+");
if (flock($file,LOCK_SH))
fwrite($file,"India
is a great country");
else
echo "locking
problem in file";
?>
Output
ram.txt is not cotaining any thing as LOCK_SH makes the lock for
reader and
doesn't allow for writing
Code
<?php
$file =
fopen("c:/rose1/ram.txt","w+");
if (flock($file,LOCK_EX))
fwrite($file,"India
is a great country");
else
echo "locking
problem in file";
?>
Output
now ram.txt has India is a great country
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.