From the course: PHP Techniques: Working with Files and Directories
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Creating and deleting directories - PHP Tutorial
From the course: PHP Techniques: Working with Files and Directories
Creating and deleting directories
- [Instructor] In this movie we'll learn how to use PHP to create and delete directories. You can make a new directory with the PHP function, mkdir, short for make directory. You can give the function argument which is an absolute path or a relative path. If you just pass in a name, it would create a directory with that name in the current working directory. It returns true or false and also gives a warning level error if the directory already exists. You may want to use it with the file exists function. If the directory doesn't exist, create it. If it exists, do nothing. The PHP function rmdir does the opposite. It removes a directory. It also takes a directory path and returns true or false. PHP will not delete a directory if it's not empty or if it's open, which we'll learn how to do in the next movie. For now, let's try these functions out. Let's create a new file and save it as dir_create.php. And I'll put my…
Contents
-
-
-
-
(Locked)
Directory basics4m 4s
-
(Locked)
Creating and deleting directories2m 53s
-
(Locked)
Accessing directory contents6m 18s
-
(Locked)
Skipping directory entries3m 23s
-
Pattern matching with glob5m 13s
-
(Locked)
Challenge: Directory treasure hunt1m 57s
-
(Locked)
Solution: Directory treasure hunt3m 49s
-
(Locked)
-
-