473,396 Members | 1,918 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Does a fopen with 'b' mode suppress magic_quotes_runtime ?

Hello,

The PHP documentation contains a user note which says that opening a
file in binary mode ('b' flag) replaces the need to set
magic_quotes_runtime to off before every read and writes.

As it seems not to correspond to the rest of the documentation (I
thought that the 'b' mode was used only for Windows end of lines), can
somebody please tell me if it is right or wrong ?

I am developping a library which needs to read binary data from files
and, as I have to deal with a possible setting of magic_quotes_runtime
to on, it would make it much simpler if it could be specified at
fopen() time.

Thanks in advance

François

Mar 30 '06 #1
3 1816
"fl*******@yahoo.fr" <fl*******@yahoo.fr> writes:
Hello,

The PHP documentation contains a user note which says that opening a
file in binary mode ('b' flag) replaces the need to set
magic_quotes_runtime to off before every read and writes.

As it seems not to correspond to the rest of the documentation (I
thought that the 'b' mode was used only for Windows end of lines), can
somebody please tell me if it is right or wrong ?

I am developping a library which needs to read binary data from files
and, as I have to deal with a possible setting of magic_quotes_runtime
to on, it would make it much simpler if it could be specified at
fopen() time.


b is for binary. When you open for example an image you should put b on.

From the manual:
If you do not specify the 'b' flag when working with binary files, you
may experience strange problems with your data, including broken image
files and strange problems with \r\n characters.

As far as I know it has nothing to do with magic_quotes_runtime

--
Henrik Hansen
Mar 30 '06 #2

fl*******@yahoo.fr wrote:
Hello,

The PHP documentation contains a user note which says that opening a
file in binary mode ('b' flag) replaces the need to set
magic_quotes_runtime to off before every read and writes.

As it seems not to correspond to the rest of the documentation (I
thought that the 'b' mode was used only for Windows end of lines), can
somebody please tell me if it is right or wrong ?

I am developping a library which needs to read binary data from files
and, as I have to deal with a possible setting of magic_quotes_runtime
to on, it would make it much simpler if it could be specified at
fopen() time.

Thanks in advance

François


Opening a file with 'b' does not suppress magic_quotes_runtime. If it
is turned on, then file(), fread(), file_get_contents(), and others
will add slashes to their results.

Do people really use magic_quotes_runtime?

Mar 30 '06 #3
OK. Thank you. I just had a doubt because of this strange comment from
'tilman DOT schroeder AT gmx DOT de' on
http://www.php.net/manual/en/functio...es-runtime.php.

I don't know if people use this f... option, but if I want to be able
to run everywhere before PHP 6 suppresses this option, I must take it
into account. And, if I want to be compatible with PHP 6, I must check
the PHP version before calling set_magic_quotes_runtime().

Mar 30 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: lkrubner | last post by:
I want to give users the power to edit files from an easy interface, so I create a form and a PHP script called "fileUpdate". It does a reasonable about of error checking and prints out some...
2
by: Mike | last post by:
I am sure that I am making a simple boneheaded mistake and I would appreciate your help in spotting in. I have just installed apache_2.0.53-win32-x86-no_ssl.exe php-5.0.3-Win32.zip...
2
by: Joseph S. | last post by:
Hi all, Consider this case: I have a free php hosting account (a LAMP host) with an account name (also the name of my directory) 'sample'. Under 'sample', I have php scripts which can create...
38
by: Martin Marcher | last post by:
Hi, I've read several questions and often the answer was 'C knows nothing about .' So if C knows that little as some people say, what are the benefits, I mean do other languages know more...
24
by: Sunner Sun | last post by:
Hi! I have looked through the FAQ but found nothing about it. :-) It seems that this kind of macro is platform dependent, doesn't it? Thank you. Sunner Sun
1
by: msnews.microsoft.com | last post by:
Help! I'm working with a mixed mode project in which some existing code is calling fopen. ie., void SomeMethod(char* fileName) { FILE* filePointer; filePointer = fopen(fileName, "r");
25
by: subramanian100in | last post by:
Consider the following program: #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv) { if (argc != 2) { printf("Usage: <program-name<text-file>\n");
16
by: Hans Fredrik Nordhaug | last post by:
I'm trying to write to a file in the current directory - no remote files. The subject says it all - I can add that both the directory and the file is wordwritable. This happens on a (quite good)...
20
by: cscorley | last post by:
For some reason, I cannot use fopen() on the file in write mode. The file "time" is in the same directory as the .php file, with permissions set to 0766. PHP Version 5.2.5 Apache/2.2.8 code...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.