PHP opendir() Function – Open Directory

Open Directory in PHP – opendir() Function

The opendir() function is used to open files from directory.

opendir() function syntax


$dir = opendir(“directory_name”);


opendir() function Example

Here, we use opendir() function to open directory “meera” and store in $dir variable, we use the $dir variable for read content of file in future.

Read files from directory using readdir() function and opendir() function.

Exmaple of readdir() in PHP

The output is :

PHP read directory
PHP readdir function example for read files from directory.

Leave a Reply

Your email address will not be published. Required fields are marked *