eldan88 Posted February 21, 2013 Share Posted February 21, 2013 Hey, I have a question about the file modifiers. I understand that the w+ and a+ is to read and write. But lets say I pass in w+ after a file name, is that going to read and write to the file? Why can't I just use r+? Thanks Quote Link to comment Share on other sites More sharing options...
mweldan Posted February 21, 2013 Share Posted February 21, 2013 if you use mode w+, will attempt to create file if not exist. if you use mode r+, will open and write into file, does not care if it exist or not. taken straightly from: http://www.php.net/manual/en/function.fopen.php Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted February 21, 2013 Share Posted February 21, 2013 From the manual: 'w+' Open for reading and writing; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it. 'a+' Open for reading and writing; place the file pointer at the end of the file. If the file does not exist, attempt to create it. 'r+' Open for reading and writing; place the file pointer at the beginning of the file. each mode has different settings that control where the pointer is to be placed, whether or not to truncate data etc.. Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 21, 2013 Share Posted February 21, 2013 http://php.net/manual/en/function.fopen.php Read the descriptions. It explains the differences. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.