Jump to content
Sign in to follow this  
johnmerlino1

Why is binary mode missing from fopen() modes?

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.

Share this post


Link to post
Share on other sites

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’);

 

Share this post


Link to post
Share on other sites

Read the manual and decide for yourself.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Read the manual and decide for yourself.

Well, I linked the manual to the original question and that actually indeed was my question - why is this mode missing and since it is missing, is it not needed anymore in PHP5?

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

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.