PHP dir() ফাংশন
প্রয়োগ
dir() ফাংশন ব্যবহার করা:
<?php $d = dir(getcwd()); echo "হ্যান্ডল: " . $d->handle . "<br>"; echo "Path: " . $d->path . "<br>"; while (($file = $d->read()) !== false){ echo "filename: " . $file . "<br>"; } $d->close(); ?>
Result:
Handle: Resource id #2 Path: /etc/php filename: . filename: .. filename: ajax.gif filename: books.xml filename: cdcatalog.xml filename: cd_catalog.xml filename: index.asp filename: demo_array.asp filename: demo_array.htm ... ... ...
Definition and Usage
The dir() function returns an instance of the Directory class. This function is used to read a directory, including the following:
The directory to be opened specified The handle and path properties of dir() are available The handle and path properties of dir() have three methods: read(), rewind(), and close()Syntax
dir(directory,context);
Parameter | Description |
---|---|
directory | Required. Specifies the directory to be opened. |
context | Optional. |
Technical Details
Return Value: | Return an instance of the Directory class. If failed, return FALSE. |
---|---|
PHP Version: | 4.0+ |