Req #47115 [Com]: Can't use flag LOCK_SH in file_get_contents

From: Date: Sun, 06 Apr 2014 03:42:53 +0000
Subject: Req #47115 [Com]: Can't use flag LOCK_SH in file_get_contents
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-185119@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=47115&edit=1 ID: 47115 Comment by: php at richardneill dot org Reported by: marc dot bennewitz at giata dot de Summary: Can't use flag LOCK_SH in file_get_contents Status: Open Type: Feature/Change Request Package: Filesystem function related Operating System: * PHP Version: * Block user comment: N Private report: N New Comment: Writing a file can be done in a single line, with file_put_contents(). Unfortunately, file_get_contents() and file() both need 5 lines to flock() - this is more complex than it needs to be, and asymmetrical wrt file_put_contents(). $fp = fopen ($DATA_FILE,"r"); flock ($fp, LOCK_SH); $contents = file_get_contents($DATA_FILE); flock ($fp, LOCK_UN); fclose ($fp); Previous Comments: ------------------------------------------------------------------------ [2009-01-15 15:34:09] marc dot bennewitz at giata dot de change subject: Can't use flag LOCK_SH in file_get_contents ------------------------------------------------------------------------ [2009-01-15 15:32:14] marc dot bennewitz at giata dot de Description: ------------ similar to file_put_contents can use LOCK_EX ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=47115&edit=1

« previous php.bugs (#185119) next »