What is flock in PHP Filesystem
In this article I am going to explain about flock function in PHP.
PHP flock() Function
The filesystem flock function is used to locks or releases a file.
Syntax of flock function
flock(filename, lock, block) |
Parameters in flock function
It have three parameter:
Parameter |
Description |
filename |
It specifies the file to check. |
lock |
It specifies what kind of lock to use. |
block |
It is optional parameter. |
Example of filesystem flock function
<html>
<body>
<?php
$file = fopen("C:\wamp\www\Dinesh\Mcn.txt","w+");
if (flock($file,LOCK_EX))
{
fwrite($file,"Write something");
flock($file,LOCK_UN);
}
else
{
echo "Error locking file!";
}
fclose($file);
?>
</body>
</html>
|
You may also want to read these related articles :here
Ask Your Question
Got a programming related question? You may want to post your question here
Programming Answers here