Doc #65089 [Opn]: Please clarify how to use fopen modes together

From: Date: Fri, 21 Jun 2013 16:42:34 +0000
Subject: Doc #65089 [Opn]: Please clarify how to use fopen modes together
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-9964@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=65089&edit=1 ID: 65089 User updated by: truenrush at gmail dot com Reported by: truenrush at gmail dot com -Summary: Please clarify how to use modes together +Summary: Please clarify how to use fopen modes together Status: Open Type: Documentation Problem Package: Documentation problem Operating System: Any PHP Version: 5.5.0 Block user comment: N Private report: N New Comment: *Added fopen in the header to clarify which modes are confusing* Previous Comments: ------------------------------------------------------------------------ [2013-06-21 16:41:22] truenrush at gmail dot com Description: ------------ I am confused, that there are not examples how to use read-write mode (w+) with binary modificator (b). Should it be "w+b"? Or "wb+"? or "bw+"? I've spend some time to understand how it works (i can test only on linux, so i am not sure in test results about "t" mode, but read-write operations should be done same on the any OS). Please, explain on http://www.php.net/manual/en/function.fopen.php page, how can i use modes altogether, which ways are acceptable, thanks! Test script: --------------- // In this example i use "t" modificator, but it does not matter exactly // w+t $h = fopen('test.file', 'w+t'); fwrite($h, "test \ntest \ntest \n"); fseek($h, 0); $data = fread($h, filesize('test.file')); var_dump($data); // data is written and read normally fclose($h); // wt+, same result $h = fopen('test.file', 'wt+'); fwrite($h, "test \ntest \ntest \n"); fseek($h, 0); $data = fread($h, filesize('test.file')); var_dump($data); // data is written and read normally, fclose($h); Expected result: ---------------- It is decribed in documentation: 1) how it is possible to combine modes ("t" and "b" in addition to usual ones), should it be w+b, wb+, etc. What is correct syntax? 2) is it enough to use "t" mode only when reading under windows, or i should write file first of all (to replace all \n with \r\n), and then read it normally? It is not clear Actual result: -------------- Documentation description exists, but is not clear. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=65089&edit=1

« previous php.doc.bugs (#9964) next »