LinuxGuruz
Toll Free Numbers
Custom Search
MAIN MENU
Main Page
IT Jobs
IPTABLES
Linux Forum
HTML Forum
PHP Forum
MySQL Forum
Linux FAQ
Linux Articles
About Us
Privacy Policy

ADD TO FAVORITES


MARC

Mailing list ARChives
- Search by -
 Subjects
 Authors
 Bodies





FOLDOC

Computing Dictionary






Cheap UK Web Hosting Provider

Cheap Dedicated Servers UK

Cheap Linux VPS Hosting UK

Cheap Cloud Hosting UK



Icons
Icons


free brochure template
Free Brochure Template

Web Hosting

Domain Names

Web Design

Reseller Hosting

Registro de Dominios

Reseller Hosting


Toll Free Number for $2.00/Month!!!

Toll Free Number for $2.00/Month!!!
Gettting a Directory Listing

Title:       Gettting a Directory Listing
Contributor: Randall Goguen (aka Ranman)
Last Update: Tuesday July 18 21:37 EDT 2000


# Here are two examples of reading directorys. The first gets
# a simple directory listing. The second gets all files and
# directory that end with 'gif'.
#
# The @ in front of the opendir() will suppress, if any, a PHP
# error warning from, in this case, opendir() and just print
# the "Unable to open $path" message to the web browser if the
# directory doesn't exsist for example.

<html><body><?
$path = '/usr';
$dir_handle = @opendir($path) or die("Unable to open $path");
echo "Directory Listing of $path<BR>";
while ($file = readdir($dir_handle)) {
        echo "$file<br>";
}
closedir($dir_handle);

$path = 'images/';
$dir_handle = @opendir($path) or die("Unable to open $path");
echo "Directory Listing of $path<BR>";
while($file = readdir($dir_handle)) {
  if (substr($file, -3) == 'gif') {
    echo "$file<br>";
} }
closedir($dir_handle);
?></body></html>


# PHP Directory functions.

int chdir(string directory)
  Change the current directory

void closedir([int dir_handle])
  Close directory connection identified by the dir_handle

class dir(string directory)
  Directory class with properties, handle and class and methods read, rewind and close

string getcwd(void)
  Gets the current directory

int opendir(string path)
  Open a directory and return a dir_handle

string readdir([int dir_handle])
  Read directory entry from dir_handle

void rewinddir([int dir_handle])
  Rewind dir_handle back to the start



	Anyone who wishes to make additions or changes to this 
PHP Tip email them to webmaster@linuxguruz.org

	This document is Copyright (c) 1999, 2000 by LinuxGuruz

Return to the LinuxGuruz PHP Tutorials Page
Return to the LinuxGuruz Main Page


www.PHP.net Search Engine


Restrict the search to:
Copyright © 1999, 2000 The PHP Development Team.
Submit a PHP Tutorial

Title:

Contributor:

IRC NICK: (optional)

E-Mail Address: (optional)

Tutorial:

Return to the LinuxGuruz PHP Tutorials Page
Return to the LinuxGuruz Main Page

RESOURCE LINKS
Linux
Apache
HTML
PHP
MySQL
PostgreSQL
Oracle
CGI
Perl
Java
C/C++
Bash
Tcl
Networking
Security
ISP
IRC
Xwindow
Laptop
Graphics
Hardware
Reference
Misc

Broadband


filing cabinet

  • Buy Batteries for Laptops and Cameras
  • Notebooks
  • Michael Fertik
  • Reputation Defender

  • XP Style Icons
    XP Style Icons


    Network Certification


    Network Security


    Wireless Networking


    Canadian
    Web Hosting in Canada


    Drummer Portal


    Mending Media

    The Path Of
    Most Resistance


    Toll Free Number for $2.00/Month!!!

    Toll Free Number for $2.00/Month!!!


    Linux

    The Distributions





    Linux

    The Software





    Linux

    The News




    webmaster@linuxguruz.com
    Copyright © 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 and 2009 by LinuxGuruz