Pages

Filesystem in PHP

With PHP, you can access the server's filesystem. This allows you to manipulate folders and text files in PHP scripts.
For example, you can use PHP to read or write a text file. Or you can list all files in a specified folder. There are many possibilities and PHP can save you lots of tedious work.
Here, we'll look at how you can use PHP to work with folders and files. The goal is to give you a quick overview. In the next lessons, we will look more closely at the different possibilities. We will not go through all the different possibilities. Again, see the documentation for a complete listing.

Example 

<html>

 <head>
 <title>Filesystem</title>
 </head>
 <body>
  
 <?php
   
 // Find and write properties
 echo "<h1>file: lesson14.php</h1>";
 echo "<p>Was last edited: " . date("r", filemtime("lesson14.php")); 
 echo "<p>Was last opened: " . date("r", fileatime("lesson14.php")); 
 echo "<p>Size: " . filesize("lesson14.php") . " bytes";
 
 ?>

 </body>
 </html>
 

No comments:

Flag Counter
| Copyright © 2013 Remote Tutor