Updates regarding text/binary mode

On Windows, 'b' is the default as of PHP 5.0.0.


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@350008 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Christoph Michael Becker 2020-06-04 10:35:17 +00:00
parent f9e44aad38
commit 0536573944

View file

@ -205,7 +205,7 @@ $handle = fopen("c:\\folder\\resource.txt", "r");
break, you need to use the correct line-ending character(s) for your
operating system. Unix based systems use <literal>\n</literal> as the
line ending character, Windows based systems use <literal>\r\n</literal>
as the line ending characters and Macintosh based systems use
as the line ending characters and Macintosh based systems (Mac OS Classic) used
<literal>\r</literal> as the line ending character.
</para>
<para>
@ -223,29 +223,22 @@ $handle = fopen("c:\\folder\\resource.txt", "r");
of the <parameter>mode</parameter> parameter.
</para>
<para>
The default translation mode depends on the SAPI and version of PHP that
you are using, so you are encouraged to always specify the appropriate
flag for portability reasons. You should use the <literal>'t'</literal>
The default translation mode is <literal>'b'</literal>.
You can use the <literal>'t'</literal>
mode if you are working with plain-text files and you use
<literal>\n</literal> to delimit your line endings in your script, but
expect your files to be readable with applications such as notepad. You
expect your files to be readable with applications such as old versions of notepad. You
should use the <literal>'b'</literal> in all other cases.
</para>
<para>
If you do not specify the 'b' flag when working with binary files, you
If you specify the 't' flag when working with binary files, you
may experience strange problems with your data, including broken image
files and strange problems with <literal>\r\n</literal> characters.
</para>
</note>
<note>
<para>
For portability, it is strongly recommended that you always
use the 'b' flag when opening files with <function>fopen</function>.
</para>
</note>
<note>
<para>
Again, for portability, it is also strongly recommended that
For portability, it is also strongly recommended that
you re-write code that uses or relies upon the <literal>'t'</literal>
mode so that it uses the correct line endings and
<literal>'b'</literal> mode instead.