Quantcast
Channel: group5php » PHP
Viewing all articles
Browse latest Browse all 10

Working with Files in PHP

$
0
0

Found an article that caught my attention and was not disappoint by what I saw inside. The article explains how you can use PHP functions to view a file’s attributes.

File attributes are the properties of a file, for example its size, the last time it was accessed, its owner, etc. Let’s look at how you find out more about the files you’re working with.

The article contains details functions and how you can use it. Such as:

  • filesize() – To check the file’s size.
  • file_exists() – To check if the file exist.
  • fileatime() - To check when the file was last accessed.
  • filemtime() – To check when the file was last modified.
  • filectime() – To check when the file’s access permissions or file ownership was last changed.
  • is_readable() – To check whether the file is readable.
  • is_ writeable() – To check whether the file is writeable.
  • is_file() – To check whether it is a file or not.
  • is_dir() – To check whether it is a directory or not.
  • file_get_contents() – Will read the entire contents of a file.
  • fopen() – Two arguments are needed, r – read, w – write, a – append. (Eg. fopen($f, “r”))

There are also examples of how you can use these functions in the article. Once again, I found an article that I will use in practise.

Article: “Working with Files in PHP” by Iain Tench

- Robert Phan

 



Viewing all articles
Browse latest Browse all 10

Latest Images

Trending Articles





Latest Images