- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModifyDirectories.php
More file actions
Latest commit
30 lines (21 loc) · 742 Bytes
/
Copy pathModifyDirectories.php
File metadata and controls
30 lines (21 loc) · 742 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
$initialDirectory = getcwd();
//Get current directory
echo"The current working directory is " . $initialDirectory. "<br>";
//Make a new directory
if (!mkdir ('newdir/mydir', 0666, true)) {
thrownewException ("Unable to create directory");
}
//Change current directory
$newDirectory = $initialDirectory."/newdir/mydir";
if (chdir($newDirectory))
{
echo"Successfully changed the directory to: " . getcwd(). "<br>";
}
//Remove the created directory
$isChildDirectoryRemoved = rmdir($initialDirectory.'/newdir/mydir');
$isParentDirectoryRemoved = rmdir($initialDirectory.'/newdir');
if ($isChildDirectoryRemoved && $isParentDirectoryRemoved)
{
echo"Successfully removed the directory: $initialDirectory/newdir";
}