Home arrow PHP arrow Reading, Writing and Creating Files in PHP

Reading, Writing and Creating Files in PHP

Reading and writing to files can be useful if you do not require the storing of important data, such as a web counter. I must warn you though, that this method of storage should not be used to store passwords and other critical information, as it is not safe. Here we will discuss how to handle files and directories in PHP, specifically, how to create, read and write them.

TABLE OF CONTENTS:
  1. Reading, Writing and Creating Files in PHP
  2. File Permissions in a Unix Environment
  3. Writing to Files
  4. Reading from Files
By: Jacques Noah
Rating: starstarstarstarstar / 42
August 23, 2006

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

File permissions in a Windows Environment

In order to be able to read and write to files and directories on any system you need to have the right privileges. I'm using a Windows system and am logged in as  Administrator. This status gives me all the access I need to read and write to files on my system. For those of you who do not have this "status," you can set the file permissions by right clicking on the file that you want to work with. A dialog box should pop up that looks something like this:

Fig.1 Properties dialogbox...

In the screen shot you'll see various options in the permissions section of the dialog box. Clicking on the "full control" checkbox will give you full access to the file.

If you do not have the right permission set on a file and then try to open, write or read it, then you will get a error warning, as in the screen shot below:

Fig.1 Permission denied error message...



 
 
>>> More PHP Articles          >>> More By Jacques Noah
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: