PHP dir() Function

The dir() function returns an instance of the Directory class. This function is used to read a directory, which includes the following:

  • The given directory is opened
  • The two properties handle and path of dir() are available
  • Both handle and path properties have three methods: read(), rewind(), and close()
  • Example -

    The above example will output something similar to:

    Handle: Resource id #2
    Path: /etc/php5