Jump to content

Why is binary mode missing from fopen() modes?


johnmerlino1
Go to solution Solved by kicken,

Recommended Posts

Same for the 't' mode.  I think it is because there are so many caveats mentioned in the comments that one needs to be "more" aware of how and why to use both 'b' and 't' mode.

 

But if I want to open a file for reading, can I just use r or do I need to attach b as well?

 

$fp = fopen(“$DOCUMENT_ROOT/../orders/orders.txt”, ‘rb’);

 

Link to comment
Share on other sites

  • Solution

Not sure what you mean by it being missing. The binary flag is mentioned. They just don't list r and rb as different modes because it's unnecessary.

Windows offers a text-mode translation flag ('t') which will transparently translate \n to \r\n when working with the file. In contrast, you can also use 'b' to force binary mode, which will not translate your data. To use these flags, specify either 'b' or 't' as the last character of the mode parameter.

Link to comment
Share on other sites

It's been explained twice to you.  If your entire question is simply curiosity about the option, then you won't get anymore here.  And if your concern is about the accuracy of the manual, well then, you are going to have a field day with other functions.

 

Signing off - too boring.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.