php is_dir 无效_PHP is_dir()函数与示例

php is_dir 无效

PHP is_dir()函数 (PHP is_dir() function)

The full form of is_dir is "Is Directory", the function is_dir() is used to check whether a file system is a directory or whether a directory exists or not.

is_dir的完整格式为“ Is Directory”函数is_dir()用于检查文件系统是否为目录或目录是否存在。

Syntax:

句法:

    is_dir(directory);

Parameter(s):

参数:

  • directory – Directory name (or path) to be checked whether it exists or not.

    directory –要检查目录名称(或路径)是否存在。

Return value:

返回值:

It returns a Boolean value, "TRUE" (1) – if directory exists or "FALSE" (null) – if the directory does not exist.

如果目录存在,则返回布尔值“ TRUE”(1)-如果目录不存在,则返回“ FALSE”(空)。

Example: PHP code to check whether a directory exists or not

示例:检查目录是否存在PHP代码

<?php
    //creating directories
    mkdir("/home/folder1");
    mkdir("/home/folder2");
    mkdir("/home/folder3");
    
    //checking directories are exist or not
    echo is_dir("/home/folder1")."<br/>";
    echo is_dir("/home/folder2")."<br/>";
    echo is_dir("/home/folder3")."<br/>";
    echo is_dir("/home/folder4")."<br/>";
    
    //checking through the conditions
    if(is_dir("/home/folder1"))
        echo "/home/folder1 exists"."<br/>";
    else
        echo "/home/folder1 does not exist"."<br/>";

    if(is_dir("/home/folder2"))
        echo "/home/folder2 exists"."<br/>";
    else
        echo "/home/folder2 does not exist"."<br/>";

    if(is_dir("/home/folder3"))
        echo "/home/folder3 exists"."<br/>";
    else
        echo "/home/folder3 does not exist"."<br/>";

    if(is_dir("/home/folder4"))
        echo "/home/folder4 exists"."<br/>";
    else
        echo "/home/folder4 does not exist"."<br/>";        
?>

Output

输出量

1
1
1

/home/folder1 exists
/home/folder2 exists
/home/folder3 exists
/home/folder4 does not exist


翻译自: https://www.includehelp.com/php/is_dir-function-with-example.aspx

php is_dir 无效

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值