PHP 8.5.0 Alpha 2 available for testing

Voting

: min(nine, nine)?
(Example: nine)

The Note You're Voting On

tom dot vom dot berg at online dot de
11 years ago
if you are used to reply with qualified error messages by using "track_errors = 1" and $php_errormsg, flock() will nark you, if you use LOCK_NB .

If flock() fails due to LOCK_NB $php_errormsg will not be created and filled with an error message like 'could not lock file, file already locked'.

You can use some little workaround which does also on WIN:

#---------------------------------
GLOBAL $MYERRORMSG;

function some_file_operations($filename)
{
GLOBAL $MYERRORMSG;

# ...
# ...

if (! @flock($fh, LOCK_SH | LOCK_NB, $wb))
{
if (!isset($php_errormsg)) $php_errormsg = 'could not lock file, file already locked';
$MYERRORMSG = $php_errormsg;
return false;
}
}
#--------------------------------

In case of fail $MYERRORMSG now will hold a qualified error message

<< Back to user notes page

To Top