Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如果php中已经存在目录,则不要创建该目录_Php_Directory - Fatal编程技术网

如果php中已经存在目录,则不要创建该目录

如果php中已经存在目录,则不要创建该目录,php,directory,Php,Directory,我正在使用以下命令为每个客户在intranet应用程序上创建一个目录。问题是,如果目录已经存在,我将收到错误: Warning: mkdir() [function.mkdir]: File exists in C:\server2go\server2go\htdocs\customermgr\administrator\components\com_chronoforms\form_actions\custo m_code\custom_code.php(18) : eval()

我正在使用以下命令为每个客户在intranet应用程序上创建一个目录。问题是,如果目录已经存在,我将收到错误:

Warning: mkdir() [function.mkdir]: File exists in     C:\server2go\server2go\htdocs\customermgr\administrator\components\com_chronoforms\form_actions\custo    m_code\custom_code.php(18) : eval()'d code on line 11
 Failed to create directory...
如果目录已经存在,脚本是否可能不创建目录?是否显示错误

    <?php
    $customerID = $_GET['cfid'];

    /* wherever this particular script will be installed, I want to create a subfolder */ 

    /* Step 1. I need to know the absolute path to where I am now, ie where this script is running from...*/ 
    $thisdir = getcwd(); 

    /* Step 2. From this folder, I want to create a subfolder called "myfiles".  Also, I want to try and make this folder world-writable (CHMOD 0777). Tell me if success or failure... */ 

    if(mkdir($thisdir ."/customer-files/$customerID" , 0777)) 
    { 
       echo "Directory has been created successfully..."; 
    } 
    else 
    { 
       echo "Failed to create directory..."; 


    } 

    ?>

编辑>>>>>>>>>>>>>

我尝试过以下方法,但仍然没有乐趣:-(


只需使用
is_dir
和/或
文件_exists
,并且仅在返回false时调用
mkdir

[编辑]


等等,我刚才在您的错误消息中发现了一个
eval

您可以使用
is\u dir
文件\u exists
来查看目录是否存在:

if(file_exists($dirname) && is_dir($dirname)) {

是的。在PHP中使用
\uuu
时完全是随机的。
if(file_exists($dirname) && is_dir($dirname)) {