How to open a file in PHP
read and write files is one of the most common programming tasks. You can not process the data if we do not get it from somewhere (most often a file), and that is usually necessary to store the result of the transformation into something different from the volatile RAM. Once again, one of the most common is a file in which you write the result of treatment. Of course, if you want to be able to read and write to files, you need to know how to open .
open a file in PHP as read-only
Use the ‘r’ option to open a file as read-only. When a file is opened as read-only, the file pointer is placed on top of the file and start reading from there. = $ Myfile “simpleFile.txt”; $ FH = fopen ($ myfile, ‘r’) or die ( “Can not open file”); fclose ($ FH );
Use the advanced mode, with the ‘r’, to open a file for reading. The ‘r’ option opens a file for both reading and writing. As with the “r” option, the file is the pointer at the beginning of the file. = $ Myfile “simpleFile.txt”; $ FH = fopen ($ myfile, ‘r’) or die ( “Can not open file”); fclose ($ FH );
Open a file as Write-Only
Use the ‘w’, to open a file - such as writing. It is important to note that this option clears the contents of the file, the punter places in the top of the file and begins to write from there. = $ Myfile “simpleFile.txt”>
Use more advanced way, 'w', to open a file for writing. The 'w' option opens a file for both reading and writing. The difference with 'r' is that 'w' option erases all the information on file when the file is opened. = $ Myfile "simpleFile.txt">
Open a file to add
Use the ‘a’ option to open the file for writing. The data file is not deleted, and the file pointer is placed at the end of the file for you to start writing the new content after existing data. = $ Myfile “simpleFile.txt”; $ FH = fopen ($ myfile, ‘A’) or die ( “Can not open file”); fclose ($ FH );
Use the most advanced ‘to’ option to open the file to add. The difference with ‘r’ is that the file pointer is placed at the end of the file. = $ Myfile “simpleFile.txt”; $ FH = fopen ($ myfile, ‘a’) or die ( “Can not open file”); fclose ($ FH );
Featured Links:
Proven Money Maker At $9,547 A Day.
Burn The Fat - Top Selling Fat Loss Ebook Since 2003.
Have You Ever Stayed Awake at Night Stressing About Whether or Not Your Marriage Will Last ... And What You Can Possibly Do to Save It?
Scan your computer for hidden AdWare and Spyware, Remove them permanently.
Join the Internet revolution and start downloading free movies and more!
Internet Marketer Gets $87 Million in Google Pay-Per-Click Ads FREE! ... And Makes Over $314 Million as a Result! ...And Now He's Going to Give You This Same Secret for Next to Nothing!








Leave a comment
You must be logged in to post a comment.