PHP Create directory with PHP delete directory code _php tutorial

Source: Internet
Author: User
Create a directory with mkdir there is a bit like dos inside the creation of the directory Oh, the method is very simple, about the deletion of the directory, here with the rmdir, but only delete empty directory, you can not delete files or folders inside the directory, if you want to delete is not empty directory will be removed with a recursive return

PHP Tutorial Create directory with PHP delete directory code
/*
This is a tutorial article, to show you how to use PHP to create a directory to delete the directory method, let's look at the creation of the directory instance. But it's OK to create a directory with Web permissions.
*/

$dir _name = "www.bkjia.com";

if (mkdir ($dir _name))//Create a directory under the current directory Tmp_data
{
echo "Catalog". $dir _name. " Create success! ";

Create a file Tmp.txt in the directory Tmp_data and write some content to it
if ($fp = fopen ($dir _name. ") /www.bkjia.com.txt ", ' a '))
{
if (fwrite ($fp, "put some contenets into file."))
{
echo "

";
echo "in Directory". $dir _name. " Under Create file Tmp.txt ";
}
}
}
Else
{
echo "Failed to create directory!" ";
Exit
}
echo " ";

if (RmDir ($dir _name))//try to delete the directory Tmp_data
{
echo "Delete directory". $dir _name. " Success! ";
}
Else
{
echo "Failed to delete directory!" ";
Exit
}

/*
Summarize:
Create a directory with mkdir there is a bit like dos inside the creation of the directory Oh, the method is very simple, about the deletion of the directory, here with the rmdir, but only delete empty directory, you can not delete files or folders inside the directory, if you want to delete is not empty directory will be removed with a recursive return
*/


http://www.bkjia.com/PHPjc/445437.html www.bkjia.com true http://www.bkjia.com/PHPjc/445437.html techarticle Create a directory with mkdir there is a bit like DOS inside the creation directory Oh, the method is very simple, about the delete directory, here with RmDir, but only delete empty directory, can not delete the file or text inside ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.