Home  >  Article  >  Backend Development  >  How to use php opendir function

How to use php opendir function

藏色散人
藏色散人Original
2019-02-19 16:18:112481browse

php opendir() function is used to open a directory handle. Its syntax is opendir(path,context). The parameter path is required and refers to the directory path to be opened.

How to use php opendir function

#How to use php opendir function?

php opendir() function syntax

Function: open the directory handle.

Syntax:

opendir(path,context);

Parameters:

path Required. Specifies the directory path to be opened.

context Optional. Specifies the environment for directory handles. context is a set of options that modify the behavior of the directory stream.

Description:

If successful, the directory handle resource will be returned. Returns FALSE on failure. If the path is not a legal directory, or the directory cannot be opened due to licensing restrictions or file system errors, an error of level E_WARNING is thrown.

php opendir() function example

<?php
$file = "/phpstudy/WWW/";
if (opendir($file))
{
    echo "打开目录成功";
}else{
    echo "打开目录失败";
}
?>

This article is an introduction to the PHP opendir function. I hope it will be helpful to friends in need!

The above is the detailed content of How to use php opendir function. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn