ADBRITE ads links
You are here: CodeIdol.com > Php > PHP 5 in Practice > Files And Directories
PHP 5 in Practice
| 8. Files and Directories
As is necessary for any language, PHP has a complete set of file and directory support functions. However, one feature that makes these functions particularly useful in a web environment is the capability to operate ...
|
|
| 8.1. Generating a Full Directory Listing
Most web servers display a list of all files in a directory for you, allowing users to select any one of their choosing. However, this is usually turned off for security reasons. You don't want users stum...
|
|
| 8.2. Natural Display of File Sizes
Listing 8.1.1 gave a way to visibly display a directory listing. There was one odd part to it though. When displaying the file sizes, they were shown in bytes because this is what the size of a file is returned t...
|
|
| 8.3. Renaming All Files Within a Directory
PHP is well known as a web programming language; however, it is also useful as a command-line scripting language. Most distributions of PHP now come with the command-line version by default. As an examp...
|
|
| 8.4. Search for Filenames Within a Directory Tree
Another common task using the file system is the need to find a file of a certain name. This can be useful either in command-line programming to replace similar tools that the operating system prov...
|
|
| 8.5. Handling Relative and Absolute File Paths
When working on the Web, or just with your local file system, you have to deal with the difference between a relative and an absolute file path. An absolute path contains the directory structure withi...
|
|
| 8.6. Reading a File Via HTTP or FTP
Built into the core of the PHP file-handling system is support for accessing files across a network. All that you need to do to use this is use a full URL instead of a filename when using any file access funct...
|
|
| 8.7. Watching the Contents of a File As It Grows (Simulating UNIX tail -f)
UNIX has a program called tail that is useful for watching the contents of a file. Normally it simply shows the last lines of a file; however, when invoked as tail -f it ke...
|
|
| 8.8. Generating a Difference Report Between Two Files
Finding changes between two versions of a file is a common taskthat's why the UNIX program diff and other such utilities exist. It can be useful to have a PHP version of this utility, one that ...
|
|
| 8.9. Locking a File for Exclusive Use
The Web, by its nature, will have multiple people running the same script/web page at the exact same time. This can cause a problem if you have a page that is updating a file. Two scripts can have race condi...
|
|
| 8.10. Caching Remote Files Locally
Often a website may include files from another website. These could be graphics, XML data, JavaScript or even some embedded HTML. There are often good reasons for doing this, such as including a banner graphic ...
|
|
| 8.11. Compressing and Uncompressing Files
File space and network bandwidth are always at a premium, and therefore compressing data is usually a good thing. PHP provides a set of functions that allow you to deal with compressed files and make them ...
|
|
| 8.12. Automatically Including Certain Files from the Parent Tree
A semicommon templating technique is to have identically named files with variables and functions in them that vary for each subdirectory that they are in. This way you can customi...
|
|
You are here: CodeIdol.com > Php > PHP 5 in Practice > Files And Directories
|
|
Related tags
Popular Categories
Unix books and guides
AJAX popular information
C# language guides
Windows books and cookbooks
.......
|
|